code: def __init__(self, cfg: Wav2Vec2Config):
      super().__init__()
      self.cfg = cfg
  
      feature_enc_layers = eval(cfg.conv_feature_layers)
      self.embed = feature_enc_layers[-1][0]
  
      self.feature_extractor = ConvFeatureExtractionModel(
          conv_layers=feature_enc_layers,
          dropout=0.0,
          mode=cfg.extractor_mode,
          conv_bias=cfg.conv_bias,
      )
  
      self.post_extract_proj = (
          nn.Linear(self.embed, cfg.encoder_embed_dim)
          if self.embed != cfg.encoder_embed_dim
          and not cfg.quantize_input
          else None
      )
  
      self.crop_seq_to_multiple = cfg.crop_seq_to_multiple
  
      self.mask_prob = cfg.mask_prob
      self.mask_selection = cfg.mask_selection
      self.mask_other = cfg.mask_other
      self.mask_length = cfg.mask_length
      self.no_mask_overlap = cfg.no_mask_overlap
      self.mask_min_space = cfg.mask_min_space
  
      self.mask_channel_prob = cfg.mask_channel_prob
      self.mask_channel_before = cfg.mask_channel_before
      self.mask_channel_selection = cfg.mask_channel_selection
      self.mask_channel_other = cfg.mask_channel_other
      self.mask_channel_length = cfg.mask_channel_length
      self.no_mask_channel_overlap = cfg.no_mask_channel_overlap
      self.mask_channel_min_space = cfg.mask_channel_min_space
  
      self.dropout_input = nn.Dropout(cfg.dropout_input)
      self.dropout_features = nn.Dropout(cfg.dropout_features)
  
      self.feature_grad_mult = cfg.feature_grad_mult
  
      self.quantizer = None
      self.input_quantizer = None
  
      self.n_negatives = cfg.num_negatives
      self.cross_sample_negatives = cfg.cross_sample_negatives
      self.codebook_negatives = cfg.codebook_negatives
      self.negatives_from_everywhere = cfg.negatives_from_everywhere
  
      self.logit_temp = cfg.logit_temp
  
      final_dim = (
          cfg.final_dim if cfg.final_dim > 0 else cfg.encoder_embed_dim
      )
  
      if cfg.quantize_targets:
          vq_dim = cfg.latent_dim if cfg.latent_dim > 0 else final_dim
          self.quantizer = GumbelVectorQuantizer(
              dim=self.embed,
              num_vars=cfg.latent_vars,
              temp=cfg.latent_temp,
              groups=cfg.latent_groups,
              combine_groups=False,
              vq_dim=vq_dim,
              time_first=True,
              weight_proj_depth=cfg.quantizer_depth,
              weight_proj_factor=cfg.quantizer_factor,
          )
          self.project_q = nn.Linear(vq_dim, final_dim)
      else:
          self.project_q = nn.Linear(self.embed, final_dim)
  
      if cfg.quantize_input:
          if cfg.same_quantizer and self.quantizer is not None:
              vq_dim = final_dim
              self.input_quantizer = self.quantizer
          else:
              vq_dim = (
                  cfg.latent_dim
                  if cfg.latent_dim > 0
                  else cfg.encoder_embed_dim
              )
              self.input_quantizer = GumbelVectorQuantizer(
                  dim=self.embed,
                  num_vars=cfg.latent_vars,
                  temp=cfg.latent_temp,
                  groups=cfg.latent_groups,
                  combine_groups=False,
                  vq_dim=vq_dim,
                  time_first=True,
                  weight_proj_depth=cfg.quantizer_depth,
                  weight_proj_factor=cfg.quantizer_factor,
              )
          self.project_inp = nn.Linear(vq_dim, cfg.encoder_embed_dim)
  
      self.mask_emb = nn.Parameter(
          torch.FloatTensor(cfg.encoder_embed_dim).uniform_()
      )
      encoder_cls = TransformerEncoder
      if cfg.layer_type == "conformer" and cfg.pos_enc_type in [
          "rel_pos",
          "rope",
      ]:
          encoder_cls = ConformerEncoder
  
      self.encoder = encoder_cls(cfg)
      self.layer_norm = LayerNorm(self.embed)
  
      self.target_glu = None
      if cfg.target_glu:
          self.target_glu = nn.Sequential(
              nn.Linear(final_dim, final_dim * 2), nn.GLU()
          )
  
      self.final_proj = nn.Linear(cfg.encoder_embed_dim, final_dim)
  
imports: import math
  from dataclasses import dataclass, field
  from typing import List, Tuple
  import numpy
  import torch
  import torch.nn
  import torch.nn.functional
  from fairseq import utils
  from fairseq.data.data_utils import compute_mask_indices
  from fairseq.dataclass import ChoiceEnum, FairseqDataclass
  from fairseq.distributed import fsdp_wrap
  from fairseq.models import BaseFairseqModel, register_model
  from fairseq.distributed.fully_sharded_data_parallel import FullyShardedDataParallel
  from fairseq.modules import Fp32GroupNorm, Fp32LayerNorm, GradMultiply, GumbelVectorQuantizer, LayerNorm, MultiheadAttention, RelPositionalEncoding, SamePad, TransposeLast
  from fairseq.modules.checkpoint_activations import checkpoint_wrapper
  from fairseq.modules.conformer_layer import ConformerWav2Vec2EncoderLayer
  from fairseq.modules.transformer_sentence_encoder import init_bert_params
  from fairseq.utils import buffered_arange, index_put, is_xla_tensor
  from .utils import pad_to_multiple
label_desc: Use image node_id 1 to create a new Wav2Vec2Model object from inherited base classes: BaseFairseqModel with example: obj = Wav2Vec2Model(cfg)