class_docstr: Encoder module.
  
  Args:
      idim: Input dimension.
      etype: Encoder units type.
      elayers: Number of encoder layers.
      eunits: Number of encoder units per layer.
      eprojs: Number of projection units per layer.
      subsample: Subsampling rate per layer.
      dropout_rate: Dropout rate for encoder layers.
      intermediate_encoder_layers: Layer IDs for auxiliary encoder output sequences.
class_docstr_tok: ["Encoder","module",".","Args",":","idim",":","Input","dimension",".","etype",":","Encoder","units","type",".","elayers",":","Number","of","encoder","layers",".","eunits",":","Number","of","encoder","units","per","layer",".","eprojs",":","Number","of","projection","units","per","layer",".","subsample",":","Subsampling","rate","per","layer",".","dropout_rate",":","Dropout","rate","for","encoder","layers",".","intermediate_encoder_layers",":","Layer","IDs","for","auxiliary","encoder","output","sequences","."]
docstr: Forward encoder.
  
  Args:
      feats: Feature sequences. (B, F, D_feats)
      feats_len: Feature sequences lengths. (B,)
      prev_states: Previous encoder hidden states. [N x (B, T, D_enc)]
  
  Returns:
      enc_out: Encoder output sequences. (B, T, D_enc)
             with or without encoder intermediate output sequences.
             ((B, T, D_enc), [N x (B, T, D_enc)])
      enc_out_len: Encoder output sequences lengths. (B,)
      current_states: Encoder hidden states. [N x (B, T, D_enc)]
docstr_tok: ["Forward","encoder",".","Args",":","feats",":","Feature","sequences",".","(","B",",","F",",","D_feats",")","feats_len",":","Feature","sequences","lengths",".","(","B",",",")","prev_states",":","Previous","encoder","hidden","states",".","[","N","x","(","B",",","T",",","D_enc",")","]","Returns",":","enc_out",":","Encoder","output","sequences",".","(","B",",","T",",","D_enc",")","with","or","without","encoder","intermediate","output","sequences",".","(","(","B",",","T",",","D_enc",")",",","[","N","x","(","B",",","T",",","D_enc",")","]",")","enc_out_len",":","Encoder","output","sequences","lengths",".","(","B",",",")","current_states",":","Encoder","hidden","states",".","[","N","x","(","B",",","T",",","D_enc",")","]"]
code: def forward(
      self,
      feats: torch.Tensor,
      feats_len: torch.Tensor,
      prev_states: Optional[List[torch.Tensor]] = None,
  ):
      """Forward encoder.
  
      Args:
          feats: Feature sequences. (B, F, D_feats)
          feats_len: Feature sequences lengths. (B,)
          prev_states: Previous encoder hidden states. [N x (B, T, D_enc)]
  
      Returns:
          enc_out: Encoder output sequences. (B, T, D_enc)
                 with or without encoder intermediate output sequences.
                 ((B, T, D_enc), [N x (B, T, D_enc)])
          enc_out_len: Encoder output sequences lengths. (B,)
          current_states: Encoder hidden states. [N x (B, T, D_enc)]
  
      """
      if prev_states is None:
          prev_states = [None] * len(self.enc)
      assert len(prev_states) == len(self.enc)
  
      _enc_out = feats
      _enc_out_len = feats_len
      current_states = []
      for rnn_module, prev_state in zip(self.enc, prev_states):
          _enc_out, _enc_out_len, states = rnn_module(
              _enc_out,
              _enc_out_len,
              prev_states=prev_state,
          )
          current_states.append(states)
  
      if isinstance(_enc_out, tuple):
          enc_out, aux_enc_out = _enc_out[0], _enc_out[1]
          enc_out_len, aux_enc_out_len = (
              _enc_out_len[0],
              _enc_out_len[1],
          )
  
          enc_out_mask = to_device(
              enc_out, make_pad_mask(enc_out_len).unsqueeze(-1)
          )
          enc_out = enc_out.masked_fill(enc_out_mask, 0.0)
  
          for i in range(len(aux_enc_out)):
              aux_mask = to_device(
                  aux_enc_out[i],
                  make_pad_mask(aux_enc_out_len[i]).unsqueeze(-1),
              )
              aux_enc_out[i] = aux_enc_out[i].masked_fill(aux_mask, 0.0)
  
          return (
              (enc_out, aux_enc_out),
              (enc_out_len, aux_enc_out_len),
              current_states,
          )
      else:
          enc_out_mask = to_device(
              _enc_out, make_pad_mask(_enc_out_len).unsqueeze(-1)
          )
  
          return (
              _enc_out.masked_fill(enc_out_mask, 0.0),
              _enc_out_len,
              current_states,
          )
  
imports: from argparse import Namespace
  from typing import List, Optional, Tuple, Union
  import numpy
  import torch
  import torch.nn.functional
  from torch.nn.utils.rnn import pack_padded_sequence, pad_packed_sequence
  from espnet.nets.e2e_asr_common import get_vgg2l_odim
  from espnet.nets.pytorch_backend.nets_utils import make_pad_mask, to_device
label_desc: Use image node_id 2 for calling the Encoder obj's underlying member method code with example usage: obj.forward(feats, feats_len, prev_states) and returns: enc_out,  aux_enc_out,  enc_out_len,  aux_enc_out_len,  current_states, _enc_out,  _enc_out_len,  current_states