class_docstr: FairSeq Hubert encoder module, used for loading pretrained weight and finetuning
  
  Args:
      input_size: input dim
      hubert_url: url to Hubert pretrained model
      hubert_dir_path: directory to download the Wav2Vec2.0 pretrained model.
      output_size: dimension of attention
      normalize_before: whether to use layer_norm before the first block
      freeze_finetune_updates: steps that freeze all layers except output layer
          before tuning the whole model (nessasary to prevent overfit).
      dropout_rate: dropout rate
      activation_dropout: dropout rate in activation function
      attention_dropout: dropout rate in attention
  Hubert specific Args:
      Please refer to:
      https://github.com/pytorch/fairseq/blob/master/fairseq/models/hubert/hubert.py
docstr: Forward Hubert ASR 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","Hubert","ASR","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 Hubert ASR 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 hubert parameters!")
      else:
          self.num_updates += 1
      with torch.no_grad() if not ft else contextlib.nullcontext():
          enc_outputs = self.encoders(
              xs_pad,
              padding_mask=masks,
              mask=self.apply_mask and self.training,
              features_only=True,
              output_layer=None,
          )
  
      xs_pad = enc_outputs["x"]  # (B,T,C),
      masks = enc_outputs["padding_mask"]  # (B, T)
  
      # save gpu memory
      del enc_outputs
  
      olens = (~masks).sum(dim=1)
  
      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
  
imports: import contextlib
  import copy
  import logging
  import os
  from pathlib import Path
  from typing import List, Optional, Tuple
  import torch
  import yaml
  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 FairseqHubertEncoder obj's underlying member method code with example usage: obj.forward(xs_pad, ilens, prev_states) and returns: xs_pad,  olens,  None