Assemble the torta
Position a rack in the center of the oven and heat the oven to 375°F.
Roast the squash cut side down on a lightly oiled rimmed baking sheet until tender, 45 to 50 minutes (if using butternut, roast cut side down in a single layer, flipping halfway through). Scoop the flesh from the skins and mash it with a potato masher. You’ll need 2 cups for the torta; save any extra for another use.
Bring the broth and 1 quart water to a boil in a heavy-duty 4-quart saucepan over mediumhigh heat. Slowly pour in the polenta, whisking constantly. Continue to whisk until the polenta begins to thicken, 1 to 3 minutes. Lower the heat to a gentle simmer and cook, stirring occasionally, until the polenta is tender and no longer gritty, about 40 minutes.
Meanwhile, heat the olive oil in a 12-inch nonstick skillet over medium-high heat. Add the onions and 1/2 tsp. salt. Cook, stirring often, until beginning to soften, 5 to 6 minutes. Add the thyme and paprika, reduce the heat to medium low, cover, and cook, stirring occasionally, until the onions are reduced to about a third of their original volume and look like jam, 40 to 50 minutes. Uncover, increase the heat to medium high, and add the sherry. Cook, stirring often, until the sherry is absorbed, about 2 minutes. Set aside off the heat.
Stir three-quarters of the cheese into the polenta until melted. Stir in the 2 cups mashed squash. Season to taste with salt.
Oil a 10-inch springform pan. While the polenta is still hot and soft, spoon half of it into the pan and spread it evenly. Spread the onion marmalade over the polenta in an even layer right out to the edge. Spoon the remaining polenta over the onions, spread it evenly, and score the top lightly with a fork—it will look like corduroy. Chill the torta on a rimmed baking sheet in the refrigerator until very firm, at least 2 hours and up to overnight. The onion marmalade may leak a bit, but that’s OK.
Bake the torta
Heat the oven to 350°F.
Run a knife along the inside of the springform pan to loosen the torta. Remove the side of the springform pan and use two large spatulas to carefully transfer the torta to an ovenproof serving plate. Bake until hot throughout, about 40 minutes. Sprinkle with the remaining cheese and bake until it melts, 8 to 10 minutes.
To serve, carefully and gently cut the torta into wedges. The torta is soft when hot, but it will hold its shape if you handle it gently.
The assembled torta can be made one or two days ahead and refrigerated, tightly wrapped in plastic. Let it sit on a rimmed baking sheet at room temperature for about an hour before baking as directed in the recipe.