docstr: Forward decoder.
  
  Args:
      hs_pad: encoded memory, float32  (batch, maxlen_in, feat)
      hlens: (batch)
      ys_in_pad:
          input token ids, int64 (batch, maxlen_out)
          if input_layer == "embed"
          input tensor (batch, maxlen_out, #mels) in the other cases
      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","token","ids",",","int64","(","batch",",","maxlen_out",")","if","input_layer","==","``","embed","''","input","tensor","(","batch",",","maxlen_out",",","#","mels",")","in","the","other","cases","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 token ids, int64 (batch, maxlen_out)
              if input_layer == "embed"
              input tensor (batch, maxlen_out, #mels) in the other cases
          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, )
      """
      tgt = ys_in_pad
      # tgt_mask: (B, 1, L)
      tgt_mask = (~make_pad_mask(ys_in_lens)[:, None, :]).to(tgt.device)
      tgt_max_len = tgt_mask.size(-1)
      # tgt_mask_tmp: (B, L, L)
      tgt_mask_tmp = tgt_mask.transpose(1, 2).repeat(1, 1, tgt_max_len)
      tgt_mask = tgt_mask.repeat(1, tgt_max_len, 1) & tgt_mask_tmp
  
      memory = hs_pad
      memory_mask = (~make_pad_mask(hlens))[:, None, :].to(
          memory.device
      )
  
      x = self.embed(tgt)
      x, tgt_mask, memory, memory_mask = self.decoders(
          x, tgt_mask, memory, memory_mask
      )
      if self.normalize_before:
          x = self.after_norm(x)
      if self.output_layer is not None:
          x = self.output_layer(x)
  
      olens = tgt_mask.sum(1)
      return x, olens
  
file_path: espnet/espnet2/asr/decoder/mlm_decoder.py
imports: from typing import Tuple
  import torch
  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.pytorch_backend.transformer.attention import MultiHeadedAttention
  from espnet.nets.pytorch_backend.transformer.decoder_layer import DecoderLayer
  from espnet.nets.pytorch_backend.transformer.embedding import PositionalEncoding
  from espnet.nets.pytorch_backend.transformer.layer_norm import LayerNorm
  from espnet.nets.pytorch_backend.transformer.positionwise_feed_forward import PositionwiseFeedForward
  from espnet.nets.pytorch_backend.transformer.repeat import repeat
label_desc: Use image node_id 2 for calling the MLMDecoder obj's underlying member method code with example usage: obj.forward(hs_pad, hlens, ys_in_pad, ys_in_lens) and returns: x,  olens