class_docstr: FairSeq Wav2Vec2 encoder module.
  
  Args:
      input_size: input dim
      output_size: dimension of attention
      w2v_url: url to Wav2Vec2.0 pretrained model
      w2v_dir_path: directory to download the Wav2Vec2.0 pretrained model.
      normalize_before: whether to use layer_norm before the first block
      finetune_last_n_layers: last n layers to be finetuned in Wav2Vec2.0
                              0 means to finetune every layer if freeze_w2v=False.
class_docstr_tok: ["FairSeq","Wav2Vec2","encoder","module",".","Args",":","input_size",":","input","dim","output_size",":","dimension","of","attention","w2v_url",":","url","to","Wav2Vec2.0","pretrained","model","w2v_dir_path",":","directory","to","download","the","Wav2Vec2.0","pretrained","model",".","normalize_before",":","whether","to","use","layer_norm","before","the","first","block","finetune_last_n_layers",":","last","n","layers","to","be","finetuned","in","Wav2Vec2.0","0","means","to","finetune","every","layer","if","freeze_w2v=False","."]
docstr: Forward FairSeqWav2Vec2 Encoder.
  
  Args:
      xs_pad: input tensor (B, L, D)
      ilens: input length (B)
      prev_states: Not to be used now.
  Returns:
      position embedded tensor and mask
docstr_tok: ["Forward","FairSeqWav2Vec2","Encoder",".","Args",":","xs_pad",":","input","tensor","(","B",",","L",",","D",")","ilens",":","input","length","(","B",")","prev_states",":","Not","to","be","used","now",".","Returns",":","position","embedded","tensor","and","mask"]
code: def forward(
      self,
      xs_pad: torch.Tensor,
      ilens: torch.Tensor,
      prev_states: torch.Tensor = None,
  ) -> Tuple[torch.Tensor, torch.Tensor, Optional[torch.Tensor]]:
      """Forward FairSeqWav2Vec2 Encoder.
  
      Args:
          xs_pad: input tensor (B, L, D)
          ilens: input length (B)
          prev_states: Not to be used now.
      Returns:
          position embedded tensor and mask
      """
      masks = make_pad_mask(ilens).to(xs_pad.device)
  
      ft = self.freeze_finetune_updates <= self.num_updates
      if self.num_updates <= self.freeze_finetune_updates:
          self.num_updates += 1
      elif ft and self.num_updates == self.freeze_finetune_updates + 1:
          self.num_updates += 1
          logging.info("Start fine-tuning wav2vec parameters!")
  
      with torch.no_grad() if not ft else contextlib.nullcontext():
          enc_outputs = self.encoders(
              xs_pad,
              masks,
              mask=self.training,
              features_only=True,
          )
  
      xs_pad = enc_outputs["x"]  # (B,T,C),
      bs = xs_pad.shape[0]
      if enc_outputs["padding_mask"] is not None:
          masks = enc_outputs["padding_mask"]  # (B, T)
          olens = (~masks).sum(dim=1)  # (B)
      else:
          olens = (
              torch.IntTensor([xs_pad.shape[1]])
              .repeat(bs)
              .to(xs_pad.device)
          )
  
      if self.output_layer is not None:
          xs_pad = self.output_layer(xs_pad)
  
      if self.normalize_before:
          xs_pad = self.after_norm(xs_pad)
  
      return xs_pad, olens, None
  
file_path: espnet/espnet2/asr/encoder/wav2vec2_encoder.py
imports: import contextlib
  import copy
  import logging
  import os
  from typing import Optional, Tuple
  import torch
  from filelock import FileLock
  from typeguard import check_argument_types
  from espnet2.asr.encoder.abs_encoder import AbsEncoder
  from espnet.nets.pytorch_backend.nets_utils import make_pad_mask
  from espnet.nets.pytorch_backend.transformer.layer_norm import LayerNorm
label_desc: Use image node_id 3 for calling the FairSeqWav2Vec2Encoder obj's underlying member method code with example usage: obj.forward(xs_pad, ilens, prev_states) and returns: xs_pad,  olens,  None