def __init__(self, vocab, hidden_size, latent_size, depth, stereo=True):
    super(JTNNVAE, self).__init__()
    self.vocab = vocab
    self.hidden_size = hidden_size
    self.latent_size = latent_size
    self.depth = depth
    self.embedding = nn.Embedding(vocab.size(), hidden_size)
    self.jtnn = JTNNEncoder(vocab, hidden_size, self.embedding)
    self.jtmpn = JTMPN(hidden_size, depth)
    self.mpn = MPN(hidden_size, depth)
    self.decoder = JTNNDecoder(vocab, hidden_size, (latent_size // 2), self.embedding)
    self.T_mean = nn.Linear(hidden_size, (latent_size // 2))
    self.T_var = nn.Linear(hidden_size, (latent_size // 2))
    self.G_mean = nn.Linear(hidden_size, (latent_size // 2))
    self.G_var = nn.Linear(hidden_size, (latent_size // 2))
    self.assm_loss = nn.CrossEntropyLoss(size_average=False)
    self.use_stereo = stereo
    if stereo:
        self.stereo_loss = nn.CrossEntropyLoss(size_average=False)
def __init__(self, vocab, hidden_size, latent_size, depth, stereo=True):
    super(JTNNVAE, self).__init__()
    self.vocab = vocab
    self.hidden_size = hidden_size
    self.latent_size = latent_size
    self.depth = depth
    self.embedding = nn.Embedding(vocab.size(), hidden_size)
    self.jtnn = JTNNEncoder(vocab, hidden_size, self.embedding)
    self.jtmpn = JTMPN(hidden_size, depth)
    self.mpn = MPN(hidden_size, depth)
    self.decoder = JTNNDecoder(vocab, hidden_size, (latent_size // 2), self.embedding)
    self.T_mean = nn.Linear(hidden_size, (latent_size // 2))
    self.T_var = nn.Linear(hidden_size, (latent_size // 2))
    self.G_mean = nn.Linear(hidden_size, (latent_size // 2))
    self.G_var = nn.Linear(hidden_size, (latent_size // 2))
    self.assm_loss = nn.CrossEntropyLoss(size_average=False)
    self.use_stereo = stereo
    if stereo:
        self.stereo_loss = nn.CrossEntropyLoss(size_average=False)