1/4 cup (1/2 stick or 2 ounces) butter
1 shallot, finely chopped
2 leeks, sliced
3 pounds Swiss chard, leaves and stems separated and both cut into 1-inch pieces
a pinch of freshly grated nutmeg
2 cups heavy cream or whole milk
2 garlic cloves, minced
2 tablespoons flour
2 pounds butternut squash, peeled and cut into 1/8-inch thick rounds
1 tablespoon minced fresh Italian parsley
1 tablespoon minced fresh thyme
ground black pepper
1 1/4 cups (about 5 ounces) coarsely grated Gruyere cheese
Prep greens: Cook shallot and leeks in 2 tablespoons butter in a large pan over medium heat, stirring, until softened. Add chard stems, pinch of nutmeg, and salt and pepper to taste and cook, stirring, until vegetables are tender but not browned, about 8 minutes. Increase heat to moderately high and add chard leaves by large handfuls, stirring, until all greens are wilted. Season with salt and pepper then transfer greens to a colander to drain well and press out liquid with back of a large spoon.
Make sauce: Combine cream or milk and garlic in small saucepan; bring to simmer; keep warm. Melt two tablespoons butter in a medium heavy saucepan over moderate heat and stir in flour. Cook roux, whisking, one minute, then slowly whisk in warm cream/milk and boil, whisking, one minute. Season sauce with salt and pepper.
Assemble gratin: Preheat oven to 400 degrees. Butter deep 9×13 baking dish. Spread half of butternut chunks in the prepared baking dish. Sprinkle with salt, pepper, a quarter of the herbs and a 1/4 cup of the cheese. Distribute half of the greens mixture over the cheese, then sprinkle salt, pepper, a quarter of the herbs and 1/4 cup of the cheese over it. Pour half of the bechamel sauce over the first two layers then continue with the remaining butternut chunks, more salt, pepper, herbs and cheese and then the remaining greens, salt, pepper and herbs. Pour the remaining sauce over the top of the gratin, pressing the vegetables slightly to ensure that they are as submerged as possible. Sprinkle with the last 1/4 cup of cheese.
Bake gratin for about 1 hour until golden and bubbly, and most of the liquid is absorbed. Let stand 10 minutes before serving.