class_docstr: Machine translation model which supports bottleneck architecture,
  NLL, VAE, and MIM loss.
  
  Supported losses:
    1) nll - Conditional cross entropy (the usual NMT loss)
    2) mim - MIM learning framework. A latent variable model with good
                    reconstruction and compressed latent representation.
                    https://arxiv.org/pdf/2003.02645.pdf
    3) vae - VAE learning framework. A latent variable model which learns
                    good probability estimation over observations and
                    a regularized latent representation.
                    https://arxiv.org/pdf/1312.6114.pdf
class_docstr_tok: ["Machine","translation","model","which","supports","bottleneck","architecture",",","NLL",",","VAE",",","and","MIM","loss",".","Supported","losses",":","1",")","nll","-","Conditional","cross","entropy","(","the","usual","NMT","loss",")","2",")","mim","-","MIM","learning","framework",".","A","latent","variable","model","with","good","reconstruction","and","compressed","latent","representation",".","https",":","\/\/arxiv.org\/pdf\/2003.02645.pdf","3",")","vae","-","VAE","learning","framework",".","A","latent","variable","model","which","learns","good","probability","estimation","over","observations","and","a","regularized","latent","representation",".","https",":","\/\/arxiv.org\/pdf\/1312.6114.pdf"]
code: def __init__(
      self, cfg: MTBottleneckModelConfig, trainer: Trainer = None
  ):
      super().__init__(cfg=cfg, trainer=trainer)
  
      self.model_type: str = cfg.get("model_type", "nll")
      self.min_logv: float = cfg.get("min_logv", -6)
      self.latent_size: int = cfg.get("latent_size", -1)
      self.non_recon_warmup_batches: int = cfg.get(
          "non_recon_warmup_batches", 200000
      )
      self.recon_per_token: bool = cfg.get("recon_per_token", True)
      self.log_timing: bool = cfg.get("log_timing", True)
  
      # if True, translation uses the mean of latent for VAE and MIM
      self.deterministic_translate = True
  
      # latent_size -1 will take value of encoder.hidden_size
      if self.latent_size < 0:
          self.latent_size = self.encoder.hidden_size
  
      if not self.recon_per_token:
          # disable reduction for train and eval loss
          self.eval_loss_fn = NLLLoss(
              ignore_index=self.decoder_tokenizer.pad_id,
              reduction="none",
          )
          self.loss_fn._per_token_reduction = False
  
      if self.model_type not in ["nll", "mim", "vae"]:
          raise ValueError(f"Unknown model_type = {self.model_type}")
  
      # project bridge dimension back to decoder hidden dimensions
      self.latent2hidden = build_linear_or_identity(
          self.latent_size, self.decoder.hidden_size
      )
  
      if self.model_type == "nll":
          # project dimension of encoder hidden to latent dimension
          self.hidden2latent_mean = build_linear_or_identity(
              self.encoder.hidden_size, self.latent_size
          )
      else:
          # MIM or VAE requires two independent projections for mean/variance
          # project dimension of encoder hidden to latent dimension
          self.hidden2latent_mean = torch.nn.Linear(
              self.encoder.hidden_size, self.latent_size
          )
          # for probabilistic latent variable models we also need variance
          self.hidden2latent_logv = torch.nn.Linear(
              self.encoder.hidden_size, self.latent_size
          )
  
imports: from typing import Dict, Optional
  import numpy
  import torch
  from pytorch_lightning import Trainer
  from nemo.collections.common.losses import NLLLoss
  from nemo.collections.nlp.models.machine_translation.mt_enc_dec_config import MTBottleneckModelConfig
  from nemo.collections.nlp.models.machine_translation.mt_enc_dec_model import MTEncDecModel
  from nemo.core.classes.common import typecheck
  from nemo.utils import timers
label_desc: Use image node_id 1 to create a new MTBottleneckModel object from inherited base classes: MTEncDecModel with example: obj = MTBottleneckModel(cfg, trainer)