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"]
docstr: Translates a minibatch of inputs from source language to target language.
  Args:
      src: minibatch of inputs in the src language (batch x seq_len)
      src_mask: mask tensor indicating elements to be ignored (batch x seq_len)
  Returns:
      translations: a list strings containing detokenized translations
      inputs: a list of string containing detokenized inputs
docstr_tok: ["Translates","a","minibatch","of","inputs","from","source","language","to","target","language",".","Args",":","src",":","minibatch","of","inputs","in","the","src","language","(","batch","x","seq_len",")","src_mask",":","mask","tensor","indicating","elements","to","be","ignored","(","batch","x","seq_len",")","Returns",":","translations",":","a","list","strings","containing","detokenized","translations","inputs",":","a","list","of","string","containing","detokenized","inputs"]
code: def batch_translate(
      self,
      src: torch.LongTensor,
      src_mask: torch.LongTensor,
      return_beam_scores: bool = False,
      cache={},
  ):
      """
      Translates a minibatch of inputs from source language to target language.
      Args:
          src: minibatch of inputs in the src language (batch x seq_len)
          src_mask: mask tensor indicating elements to be ignored (batch x seq_len)
      Returns:
          translations: a list strings containing detokenized translations
          inputs: a list of string containing detokenized inputs
      """
      mode = self.training
      timer = cache.get("timer", None)
      try:
          self.eval()
  
          # build posterior distribution q(x|z)
          if (
              ("z" not in cache)
              or ("z_mean" not in cache)
              or ("z_mask" not in cache)
          ):
              if timer is not None:
                  timer.start("encoder")
              enc_hiddens, enc_mask = self.encoder(
                  input_ids=src, encoder_mask=src_mask, return_mask=True
              )
              z, z_mean, _ = self.encode_latent(hidden=enc_hiddens)
              if timer is not None:
                  timer.stop("encoder")
          else:
              enc_mask = cache["z_mask"]
              z = cache["z"]
              z_mean = cache["z_mean"]
  
          if getattr(self, "deterministic_translate", True):
              z = z_mean
  
          if timer is not None:
              timer.start("sampler")
          # decoding cross attention context
          context_hiddens = self.latent2hidden(z)
  
          best_translations = self.beam_search(
              encoder_hidden_states=context_hiddens,
              encoder_input_mask=enc_mask,
              return_beam_scores=return_beam_scores,
          )
          if timer is not None:
              timer.stop("sampler")
  
          if return_beam_scores:
              (
                  all_translations,
                  scores,
                  best_translations,
              ) = best_translations
              scores = scores.view(-1)
              all_translations = self.ids_to_postprocessed_text(
                  all_translations,
                  self.decoder_tokenizer,
                  self.target_processor,
                  filter_beam_ids=True,
              )
  
          best_translations = self.ids_to_postprocessed_text(
              best_translations,
              self.decoder_tokenizer,
              self.target_processor,
              filter_beam_ids=True,
          )
          inputs = self.ids_to_postprocessed_text(
              src,
              self.encoder_tokenizer,
              self.source_processor,
              filter_beam_ids=False,
          )
  
      finally:
          self.train(mode=mode)
      if return_beam_scores:
          return (
              inputs,
              all_translations,
              scores.data.cpu().numpy().tolist(),
              best_translations,
          )
  
      return inputs, best_translations
  
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 8 for calling the MTBottleneckModel obj's underlying member method code with example usage: obj.batch_translate(src, src_mask, return_beam_scores, cache) and returns: inputs,  best_translations, inputs,  all_translations,  scores,  best_translations