Place beans in 4 cups cold water in a large saucepan and bring to a boil over medium heat. Drain and replace water. Simmer over medium-low heat until tender, about 45 minutes.
Combine masa harina, salt, and 1⁄2 cup hot water in a small bowl. Knead until smooth, about 5 minutes, then cover and set aside for 1 hour.
Rinse chiles, then place in a bowl, cover with hot water, and soak until soft, 15–20 minutes. Drain and carefully remove stems, veins, and seeds (see Handling Chiles). Purée with onions and garlic in a blender or food processor. Heat oil in a skillet over medium heat, add purée, and cook, stirring, for 5 minutes.
Wash chard in several changes of water and discard stalks. Cook in a pot of salted boiling water over medium-high heat for 10 minutes. Drain, reserving 4 cups cooking liquid.
Add chile purée, chard, and reserved liquid to beans. Cook over low heat until warm. Roll dough into 1" balls; dent each in the middle; add to soup. Add epazote, cover, and simmer for 10 minutes. Remove epazote. Serve hot.