When should one subclass nn.ModuleDict over nn.Module?
for example, here,

  
      github.com
  
  
    civodlu/trw/blob/42bb09e4bee07c85c3d9585b07e0e23f7a60906f/tutorials/dcgan_mnist.py 6
import trw.train
import trw.datasets
import torch
import torch.nn as nn
import torch.nn.functional as F
import functools
import collections

batch_size = 32
latent_size = 64
mnist_size = 28 * 28
hidden_size = 256


class Flatten(nn.Module):
    def forward(self, i):
        return i.view(i.shape[0], -1)


class Generator(nn.Module):


  This file has been truncated. show original

  
  
    
    
  
  


is it better to use nn.ModuleDict whenever merging multiple neural networks?
so,
class Y(nn.ModuleDict):
  def __init__(self):
    super().__init__()
    self['NetA'] = NetA()
    self['NetB'] = NetB()

def X(nn.Module):
  def __init__(self):
    super().__init__()
    self.modelone = NetA()
    self.modeltwo = NetB()

which is the preferred way?