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"]
code: def add_prefix_postfix(self, enc_out, hlens, ys_in_pad, ys_in_lens):
      args = {}
  
      hlens_max = (hlens + ys_in_lens).max()
  
      enc_out_list = []
  
      for i in range(len(hlens)):
          enc_out_element = [
              self.prefix.to(enc_out.device),
              enc_out[i : i + 1, : hlens[i], :],
              self.postfix.to(enc_out.device),
              self.decoder_word_embeddings(
                  ys_in_pad[i : i + 1, 1 : ys_in_lens[i]]
              ).to(enc_out.device),
          ]
  
          padding = self.decoder_word_embeddings(
              torch.tensor([[self.decoder_pad_token_id]]).to(
                  enc_out.device
              )
          ).expand(-1, hlens_max - (hlens[i] + ys_in_lens[i]), -1)
  
          if self.tokenizer_padding_side == "left":
              enc_out_element.insert(0, padding)
          else:
              enc_out_element.insert(len(enc_out_element), padding)
  
          enc_out_list.append(torch.cat(enc_out_element, dim=1))
  
      args["inputs_embeds"] = torch.vstack(enc_out_list)
  
      no_loss_lengths = (
          self.prefix.size(1) + hlens + self.postfix.size(1) - 1
      )
      inputs_lengths = no_loss_lengths + ys_in_lens
  
      hs_mask = (
          (~make_pad_mask(inputs_lengths)).to(enc_out.device).float()
      )
  
      if self.tokenizer_padding_side == "left":
          args["attention_mask"] = hs_mask.flip([1])
      else:
          args["attention_mask"] = hs_mask
  
      args["return_dict"] = True
  
      return args, no_loss_lengths
  
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 4 for calling the HuggingFaceTransformersDecoder obj's underlying member method code with example usage: obj.add_prefix_postfix(enc_out, hlens, ys_in_pad, ys_in_lens) and returns: args,  no_loss_lengths