Step 1Place the potatoes and 2 teaspoons of salt in a large pot of water (you'll be cooking the greens in the same water) and bring to a boil. Reduce the heat to medium, cover partly and boil the potatoes until tender when pierced with a knife, about 20 minutes. Meanwhile, stem the greens and wash the leaves thoroughly, making sure to remove all sand.
Step 2When the potatoes are done, remove from the water and set aside until cool enough to handle, then cut in 1/2-inch slices. Bring the water back to a rolling boil and add another teaspoon of salt and the greens. Blanch until just tender, about 2 minutes. Remove from the water with a slotted spoon or deep-fry skimmer and transfer immediately to a bowl of cold water. Drain and squeeze dry. It is not necessary to remove every drop of water. Chop coarsely and set aside.
Step 3Heat the oil over medium heat in a large nonstick skillet. Add the onion and cook, stirring, until tender, about 5 minutes. Stir in the garlic and cook, stirring, until fragrant, 30 seconds to a minute. Stir in the greens, potatoes, parsley and basil and gently toss together. Season to taste with salt and pepper, and transfer to a large bowl.
Step 4In a food processor, process the ricotta or cottage cheese until smooth. Scrape down the sides. Set aside 2 tablespoons of the beaten eggs, and add the rest to the processor, along with the milk. Beat together, then transfer to the bowl with the greens. Stir in the Gruyere and Parmesan cheeses, add more salt and pepper and the nutmeg, and combine everything thoroughly. Taste and adjust seasonings.
Step 5Heat the oven to 375 degrees. Gently punch down the pastry dough. If making a galette, roll out into a large, thin circle, about 16 inches in diameter. Top with the filling, leaving a 2 1/2-inch edge, and fold the edges in over the filling, draping folds all the way around. If you can stretch the dough up to the middle, gather the edges together and shape a little top knot. Otherwise you can leave an opening in the center. If making a torta, oil a 10-inch pie dish, springform pan or a tart pan with a removable rim. Roll out two-thirds of the dough into a thin circle, and line the pie dish or pan; ease the dough into the edges. There should be some overhang. Fill with the greens mixture. Roll out the other piece of dough into a circle, and place on top of the filling. Fold the edges of the bottom crust over the top crust, and crimp the dough all the way around the edge. Gently score the top of the dough with a paring knife. Brush the torte or galette with the reserved egg.
Step 6Bake until the top is golden brown, 45 to 50 minutes. Remove from the heat and cool for at least 10 minutes before serving. Serve hot or warm.