code: def __init__(
      self,
      z_dim,
      h_dim,
      ae_structure_z,
      ae_structure_h,
      act_fn,
      likelihood,
  ):
      super(CVAE, self).__init__()
  
      self.likelihood = likelihood
      self.act_fn = ACT.get(act_fn, None)
      if self.act_fn is None:
          raise ValueError("Supported act_fn: {}".format(ACT.keys()))
  
      # Encoder for preference data y, q(z|y)
      self.encoder_qz = nn.Sequential()
      for i in range(len(ae_structure_z) - 1):
          self.encoder_qz.add_module(
              "fc{}".format(i),
              nn.Linear(ae_structure_z[i], ae_structure_z[i + 1]),
          )
          self.encoder_qz.add_module("act{}".format(i), self.act_fn)
      self.enc_qz_mu = nn.Linear(ae_structure_z[-1], z_dim)  # mu
      self.enc_qz_logvar = nn.Linear(
          ae_structure_z[-1], z_dim
      )  # logvar
  
      # Encoder for auxiliary data x, q(h|x)
      self.encoder_qhx = nn.Sequential()
      for i in range(len(ae_structure_h) - 1):
          self.encoder_qhx.add_module(
              "fc{}".format(i),
              nn.Linear(ae_structure_h[i], ae_structure_h[i + 1]),
          )
          self.encoder_qhx.add_module("act{}".format(i), self.act_fn)
      self.enc_qhx_mu = nn.Linear(ae_structure_h[-1], h_dim)  # mu
      self.enc_qhx_logvar = nn.Linear(
          ae_structure_h[-1], h_dim
      )  # logvar
  
      # Encoder for preference data y, q(h|y)
      self.encoder_qhy = nn.Sequential()
      for i in range(len(ae_structure_z) - 1):
          self.encoder_qhy.add_module(
              "fc{}".format(i),
              nn.Linear(ae_structure_z[i], ae_structure_z[i + 1]),
          )
          self.encoder_qhy.add_module("act{}".format(i), self.act_fn)
      self.enc_qhy_mu = nn.Linear(ae_structure_z[-1], h_dim)  # mu
      self.enc_qhy_logvar = nn.Linear(
          ae_structure_z[-1], h_dim
      )  # logvar
  
      # Encoder for auxiliary data x, p(h|x)
      self.encoder_phx = nn.Sequential()
      for i in range(len(ae_structure_h) - 1):
          self.encoder_phx.add_module(
              "fc{}".format(i),
              nn.Linear(ae_structure_h[i], ae_structure_h[i + 1]),
          )
          self.encoder_phx.add_module("act{}".format(i), self.act_fn)
      self.enc_ph_mu = nn.Linear(ae_structure_h[-1], h_dim)  # mu
      self.enc_ph_logvar = nn.Linear(
          ae_structure_h[-1], h_dim
      )  # logvar
  
      # Decoder for preference data x
      ae_structure_z = [z_dim + h_dim] + ae_structure_z[::-1]
      self.decoder = nn.Sequential()
      for i in range(len(ae_structure_z) - 1):
          self.decoder.add_module(
              "fc{}".format(i),
              nn.Linear(ae_structure_z[i], ae_structure_z[i + 1]),
          )
          if i != len(ae_structure_z) - 2:
              self.decoder.add_module("act{}".format(i), self.act_fn)
  
file_path: cornac/cornac/models/cvaecf/cvaecf.py
imports: import numpy
  import torch
  import torch.nn
  import torch.nn.functional
  from tqdm.auto import trange
  from ...utils import estimate_batches
label_desc: Use image node_id 1 to create a new CVAE object from inherited base classes: nn with example: obj = CVAE(z_dim, h_dim, ae_structure_z, ae_structure_h, act_fn, likelihood)