class_docstr: ESPnet2ASRTransducerModel module definition.
  
  Args:
      vocab_size: Size of complete vocabulary (w/ SOS/EOS and blank included).
      token_list: List of tokens in vocabulary (minus reserved tokens).
      frontend: Frontend module.
      specaug: SpecAugment module.
      normalize: Normalization module.
      encoder: Encoder module.
      decoder: Decoder module.
      joint_network: Joint Network module.
      transducer_weight: Weight of the Transducer loss.
      use_k2_pruned_loss: Whether to use k2 pruned Transducer loss.
      k2_pruned_loss_args: Arguments of the k2 loss pruned Transducer loss.
      warmup_steps: Number of steps in warmup, used for pruned loss scaling.
      validation_nstep: Maximum number of symbol expansions at each time step
                        when reporting CER or/and WER using mAES.
      fastemit_lambda: FastEmit lambda value.
      auxiliary_ctc_weight: Weight of auxiliary CTC loss.
      auxiliary_ctc_dropout_rate: Dropout rate for auxiliary CTC loss inputs.
      auxiliary_lm_loss_weight: Weight of auxiliary LM loss.
      auxiliary_lm_loss_smoothing: Smoothing rate for LM loss' label smoothing.
      ignore_id: Initial padding ID.
      sym_space: Space symbol.
      sym_blank: Blank Symbol.
      report_cer: Whether to report Character Error Rate during validation.
      report_wer: Whether to report Word Error Rate during validation.
      extract_feats_in_collect_stats: Whether to use extract_feats stats collection.
class_docstr_tok: ["ESPnet2ASRTransducerModel","module","definition",".","Args",":","vocab_size",":","Size","of","complete","vocabulary","(","w\/","SOS\/EOS","and","blank","included",")",".","token_list",":","List","of","tokens","in","vocabulary","(","minus","reserved","tokens",")",".","frontend",":","Frontend","module",".","specaug",":","SpecAugment","module",".","normalize",":","Normalization","module",".","encoder",":","Encoder","module",".","decoder",":","Decoder","module",".","joint_network",":","Joint","Network","module",".","transducer_weight",":","Weight","of","the","Transducer","loss",".","use_k2_pruned_loss",":","Whether","to","use","k2","pruned","Transducer","loss",".","k2_pruned_loss_args",":","Arguments","of","the","k2","loss","pruned","Transducer","loss",".","warmup_steps",":","Number","of","steps","in","warmup",",","used","for","pruned","loss","scaling",".","validation_nstep",":","Maximum","number","of","symbol","expansions","at","each","time","step","when","reporting","CER","or\/and","WER","using","mAES",".","fastemit_lambda",":","FastEmit","lambda","value",".","auxiliary_ctc_weight",":","Weight","of","auxiliary","CTC","loss",".","auxiliary_ctc_dropout_rate",":","Dropout","rate","for","auxiliary","CTC","loss","inputs",".","auxiliary_lm_loss_weight",":","Weight","of","auxiliary","LM","loss",".","auxiliary_lm_loss_smoothing",":","Smoothing","rate","for","LM","loss","'","label","smoothing",".","ignore_id",":","Initial","padding","ID",".","sym_space",":","Space","symbol",".","sym_blank",":","Blank","Symbol",".","report_cer",":","Whether","to","report","Character","Error","Rate","during","validation",".","report_wer",":","Whether","to","report","Word","Error","Rate","during","validation",".","extract_feats_in_collect_stats",":","Whether","to","use","extract_feats","stats","collection","."]
docstr: Encoder speech sequences.
  
  Args:
      speech: Speech sequences. (B, S)
      speech_lengths: Speech sequences lengths. (B,)
  
  Return:
      encoder_out: Encoder outputs. (B, T, D_enc)
      encoder_out_lens: Encoder outputs lengths. (B,)
docstr_tok: ["Encoder","speech","sequences",".","Args",":","speech",":","Speech","sequences",".","(","B",",","S",")","speech_lengths",":","Speech","sequences","lengths",".","(","B",",",")","Return",":","encoder_out",":","Encoder","outputs",".","(","B",",","T",",","D_enc",")","encoder_out_lens",":","Encoder","outputs","lengths",".","(","B",",",")"]
code: def encode(
      self,
      speech: torch.Tensor,
      speech_lengths: torch.Tensor,
  ) -> Tuple[torch.Tensor, torch.Tensor]:
      """Encoder speech sequences.
  
      Args:
          speech: Speech sequences. (B, S)
          speech_lengths: Speech sequences lengths. (B,)
  
      Return:
          encoder_out: Encoder outputs. (B, T, D_enc)
          encoder_out_lens: Encoder outputs lengths. (B,)
  
      """
      with autocast(False):
          # 1. Extract feats
          feats, feats_lengths = self._extract_feats(
              speech, speech_lengths
          )
  
          # 2. Data augmentation
          if self.specaug is not None and self.training:
              feats, feats_lengths = self.specaug(feats, feats_lengths)
  
          # 3. Normalization for feature: e.g. Global-CMVN, Utterance-CMVN
          if self.normalize is not None:
              feats, feats_lengths = self.normalize(
                  feats, feats_lengths
              )
  
      # 4. Forward encoder
      encoder_out, encoder_out_lens = self.encoder(feats, feats_lengths)
  
      assert encoder_out.size(0) == speech.size(0), (
          encoder_out.size(),
          speech.size(0),
      )
      assert encoder_out.size(1) <= encoder_out_lens.max(), (
          encoder_out.size(),
          encoder_out_lens.max(),
      )
  
      return encoder_out, encoder_out_lens
  
imports: import logging
  from contextlib import contextmanager
  from typing import Dict, List, Optional, Tuple, Union
  import torch
  from packaging.version import parse
  from typeguard import check_argument_types
  from espnet2.asr.frontend.abs_frontend import AbsFrontend
  from espnet2.asr.specaug.abs_specaug import AbsSpecAug
  from espnet2.asr_transducer.decoder.abs_decoder import AbsDecoder
  from espnet2.asr_transducer.encoder.encoder import Encoder
  from espnet2.asr_transducer.joint_network import JointNetwork
  from espnet2.asr_transducer.utils import get_transducer_task_io
  from espnet2.layers.abs_normalize import AbsNormalize
  from espnet2.torch_utils.device_funcs import force_gatherable
  from espnet2.train.abs_espnet_model import AbsESPnetModel
label_desc: Use image node_id 4 for calling the ESPnetASRTransducerModel obj's underlying member method code with example usage: obj.encode(speech, speech_lengths) and returns: encoder_out,  encoder_out_lens