class_docstr: Hugging Face Transformers Decoder.
  
  Args:
      encoder_output_size: dimension of encoder attention
      model_name_or_path: Hugging Face Transformers model name
class_docstr_tok: ["Hugging","Face","Transformers","Decoder",".","Args",":","encoder_output_size",":","dimension","of","encoder","attention","model_name_or_path",":","Hugging","Face","Transformers","model","name"]
docstr: Forward decoder.
  
  Args:
      hs_pad: encoded memory, float32  (batch, maxlen_in, feat)
      hlens: (batch)
      ys_in_pad: input tensor (batch, maxlen_out, #mels)
      ys_in_lens: (batch)
  Returns:
      (tuple): tuple containing:
  
      x: decoded token score before softmax (batch, maxlen_out, token)
          if use_output_layer is True,
      olens: (batch, )
docstr_tok: ["Forward","decoder",".","Args",":","hs_pad",":","encoded","memory",",","float32","(","batch",",","maxlen_in",",","feat",")","hlens",":","(","batch",")","ys_in_pad",":","input","tensor","(","batch",",","maxlen_out",",","#","mels",")","ys_in_lens",":","(","batch",")","Returns",":","(","tuple",")",":","tuple","containing",":","x",":","decoded","token","score","before","softmax","(","batch",",","maxlen_out",",","token",")","if","use_output_layer","is","True",",","olens",":","(","batch",",",")"]
code: def forward(
      self,
      hs_pad: torch.Tensor,
      hlens: torch.Tensor,
      ys_in_pad: torch.Tensor,
      ys_in_lens: torch.Tensor,
  ) -> Tuple[torch.Tensor, torch.Tensor]:
      """Forward decoder.
  
      Args:
          hs_pad: encoded memory, float32  (batch, maxlen_in, feat)
          hlens: (batch)
          ys_in_pad: input tensor (batch, maxlen_out, #mels)
          ys_in_lens: (batch)
      Returns:
          (tuple): tuple containing:
  
          x: decoded token score before softmax (batch, maxlen_out, token)
              if use_output_layer is True,
          olens: (batch, )
      """
      enc_out = self.linear_in(hs_pad)
  
      if self.causal_lm:
          args, no_loss_lengths = self.add_prefix_postfix(
              enc_out, hlens, ys_in_pad, ys_in_lens
          )
      else:
          args = {"return_dict": True}
  
          if self.decoder.__class__.__name__ == "MBartDecoder":
              ys_in_pad[:, 0] = 2
  
          args["input_ids"] = ys_in_pad
          mask = (
              (~make_pad_mask(ys_in_lens)).to(ys_in_pad.device).float()
          )
          args["attention_mask"] = mask
  
          args["encoder_hidden_states"] = enc_out
          hs_mask = (~make_pad_mask(hlens)).to(hs_pad.device).float()
          args["encoder_attention_mask"] = hs_mask
  
      x = self.decoder(**args).last_hidden_state
  
      if self.causal_lm:
          if self.tokenizer_padding_side == "left":
              x = torch.vstack(
                  [
                      F.pad(
                          x[i, -ys_in_lens[i] :, :],
                          (0, 0, 0, ys_in_lens.max() - ys_in_lens[i]),
                      ).unsqueeze(0)
                      for i in range(x.shape[0])
                  ]
              )
          else:
              x = torch.vstack(
                  [
                      F.pad(
                          x[
                              i,
                              no_loss_lengths[i] : no_loss_lengths[i]
                              + ys_in_lens[i],
                              :,
                          ],
                          (0, 0, 0, ys_in_lens.max() - ys_in_lens[i]),
                      ).unsqueeze(0)
                      for i in range(x.shape[0])
                  ]
              )
  
      x = self.lm_head(x)
  
      return x, ys_in_lens
  
file_path: espnet/espnet2/asr/decoder/hugging_face_transformers_decoder.py
imports: import copy
  import logging
  from typing import Any, List, Tuple
  import torch
  import torch.nn.functional
  from typeguard import check_argument_types
  from espnet2.asr.decoder.abs_decoder import AbsDecoder
  from espnet.nets.pytorch_backend.nets_utils import make_pad_mask
  from espnet.nets.scorer_interface import BatchScorerInterface
label_desc: Use image node_id 2 for calling the HuggingFaceTransformersDecoder obj's underlying member method code with example usage: obj.forward(hs_pad, hlens, ys_in_pad, ys_in_lens) and returns: x,  ys_in_lens