Preheat oven to 375°F Butter a loaf pan and line the bottom of the pan with parchment paper, then butter it again.
Toast walnuts and cashews on a baking sheet (or you could use a hot, dry skillet set on medium and stir constantly) until lightly browned, about 10 minutes. Let cool. Chop fine with knife, (I used the food processor).
Melt butter in a sauté pan over medium heat. Add the onion and cook until translucent. Add mushrooms and cook until they're browned and any liquid from the mushrooms has reduced by half. Stir in the cooked rice, the nuts, chopped herbs, eggs, cheese, cottage cheese, minced garlic, salt, and pepper.
Spoon the mixture into the prepared pan. Smooth it down until it's level. Bake until golden brown and firm to the touch, about 1 hour. It should be firm when you shake the pan. Let cool in pan 10 minutes, then run a knife around the edge of the loaf and invert onto a serving plate. Serve with Herb Bechamel sauce or a mushroom sauce.