Melt butter in a large soup pot or large dutch oven over medium heat then add the onions. Cook the onions for approximately 5 min over medium to medium-high heat then add the sugar. Stir occasionally. Continue to cook the onions until they begin to caramelize to a deep golden brown. You do not need all onions to brown, but a good mix of caramelized onions and less cooked onions is ideal.
Once onions are caramelized, add garlic, salt and pepper and stir. Let cook for 1 minute.
Add wine to deglaze the pan and continue to cook for 2 minutes to cook out the alcohol. Scrape the bottom of the pan to release the browned bits (fond).
Add beef stock, tomato paste, bouquet garni (see notes), bay leaf and brandy. Bring to a boil then reduce heat to a simmer, partially cover the pot with a lid and continue to simmer for 30-40 minutes.
While soup is simmering, thinly slice or grate the cheese, and cut slices of crusty bread that will cover the top of the bowl. Toast bread lightly - this prevents the bread from getting too soggy once placed on top of the soup.
Once ready, taste the soup and add additional salt to taste as needed. Then ladle soup into oven-safe bowls and cover with bread. Sprinkle cheese on top of bread, as much as you prefer. Place soup bowls in an oven safe tray or dish and place them on the middle rack to broil for 2-5 minutes until cheese has melted completely and begins to brown.
Remove soup bowls from the oven and let stand for 5 minutes before serving. Top with fresh thyme leaves for garnish.