class_docstr: This lobe enables the integration of HuggingFace and SpeechBrain
  pretrained mBART models.
  
  Source paper mBART: https://arxiv.org/abs/2001.08210
  Transformer from HuggingFace needs to be installed:
  https://huggingface.co/transformers/installation.html
  
  The model is normally used as a text decoder of seq2seq models. It
  will download automatically the model from HuggingFace or use a local path.
  
  Arguments
  ---------
  source : str
      HuggingFace hub name: e.g "facebook/mbart-large-50-many-to-many-mmt"
  save_path : str
      Path (dir) of the downloaded model.
  freeze : bool (default: True)
      If True, the model is frozen. If False, the model will be trained
      alongside with the rest of the pipeline.
  target_lang: str (default: fra_Latn (a.k.a French)
      The target language code according to NLLB model.
  decoder_only : bool (default: True)
      If True, only take the decoder part (and/or the lm_head) of the model.
      This is useful in case one wants to couple a pre-trained speech encoder (e.g. wav2vec)
      with a text-based pre-trained decoder (e.g. mBART, NLLB).
  share_input_output_embed : bool (default: True)
      If True, use the embedded layer as the lm_head.
  
  Example
  -------
  >>> src = torch.rand([10, 1, 1024])
  >>> tgt = torch.LongTensor([[250008,    313,     25,    525,    773,  21525,   4004,      2]])
  >>> model_hub = "facebook/mbart-large-50-many-to-many-mmt"
  >>> save_path = "savedir"
  >>> model = mBART(model_hub, save_path) # doctest: +SKIP
  >>> outputs = model(src, tgt) # doctest: +SKIP
docstr: This method implements a forward step for mt task using a wav2vec encoder
  (same than above, but without the encoder stack)
  
  Arguments
  ----------
  src (transcription): tensor
      output features from the w2v2 encoder
  tgt (translation): tensor
      The sequence to the decoder (required).
  pad_idx : int
      The index for <pad> token (default=0).
code: def forward(self, src, tgt, pad_idx=0):
      """This method implements a forward step for mt task using a wav2vec encoder
      (same than above, but without the encoder stack)
  
      Arguments
      ----------
      src (transcription): tensor
          output features from the w2v2 encoder
      tgt (translation): tensor
          The sequence to the decoder (required).
      pad_idx : int
          The index for <pad> token (default=0).
      """
  
      # should we replace 0 elements by pax_idx as pad_idx of mbart model seems to be different from 0?
      tgt = self.custom_padding(
          tgt, 0, self.model.model.decoder.config.pad_token_id
      )
  
      if self.freeze:
          with torch.no_grad():
              if hasattr(self.model.model, "encoder"):
                  src = self.model.model.encoder(
                      inputs_embeds=src
                  ).last_hidden_state.detach()
              dec_out = self.model.model.decoder(
                  input_ids=tgt, encoder_hidden_states=src
              ).last_hidden_state.detach()
              dec_out = self.model.lm_head(dec_out).detach()
              return dec_out
  
      if hasattr(self.model.model, "encoder"):
          src = self.model.model.encoder(
              inputs_embeds=src
          ).last_hidden_state
      dec_out = self.model.model.decoder(
          input_ids=tgt, encoder_hidden_states=src
      ).last_hidden_state
      dec_out = self.model.lm_head(dec_out)
      return dec_out
  
file_path: speechbrain/speechbrain/lobes/models/huggingface_transformers/mbart.py
imports: import torch
  import logging
  from speechbrain.lobes.models.huggingface_transformers.huggingface import HFTransformersInterface
label_desc: Use image node_id 2 for calling the mBART obj's underlying member method code with example usage: obj.forward(src, tgt, pad_idx) and returns: dec_out, dec_out