class_docstr: Represents a wav2vec 2.0 model as described in
  :cite:t:`https://doi.org/10.48550/arxiv.2006.11477`.
class_docstr_tok: ["Represents","a","wav2vec","2.0","model","as","described","in",":","cite",":","t",":","`","https",":","\/\/doi.org\/10.48550\/arxiv.2006.11477","`","."]
docstr: :param encoder_frontend:
      The encoder frontend.
  :param encoder:
      The encoder (i.e. context network).
  :param masker:
      The temporal/spatial feature masker.
  :param quantizer:
      The quantizer to discretize context network targets.
  :param final_dim:
      The dimensionality of the final projection that is applied to
      context network outputs and quantized targets.
  :param final_proj_bias:
      If ``True``, the final projection learns an additive bias.
  :param num_distractors:
      The number of distractors to use in contrastive prediction.
  :param logit_temp:
      The temperature to divide logits by.
  :param diversity_loss_weight:
      The weight of diversity in loss computation.
docstr_tok: [":","param","encoder_frontend",":","The","encoder","frontend",".",":","param","encoder",":","The","encoder","(","i.e",".","context","network",")",".",":","param","masker",":","The","temporal\/spatial","feature","masker",".",":","param","quantizer",":","The","quantizer","to","discretize","context","network","targets",".",":","param","final_dim",":","The","dimensionality","of","the","final","projection","that","is","applied","to","context","network","outputs","and","quantized","targets",".",":","param","final_proj_bias",":","If","``","True","``",",","the","final","projection","learns","an","additive","bias",".",":","param","num_distractors",":","The","number","of","distractors","to","use","in","contrastive","prediction",".",":","param","logit_temp",":","The","temperature","to","divide","logits","by",".",":","param","diversity_loss_weight",":","The","weight","of","diversity","in","loss","computation","."]
code: def __init__(
      self,
      encoder_frontend: Wav2Vec2Frontend,
      encoder: TransformerEncoder,
      masker: Wav2Vec2Masker,
      quantizer: VectorQuantizer,
      final_dim: int,
      *,
      final_proj_bias: bool = True,
      num_distractors: int = 100,
      logit_temp: float = 0.1,
      diversity_loss_weight: float = 0.1,
      device: Optional[Device] = None,
      dtype: Optional[DataType] = None,
  ) -> None:
      """
      :param encoder_frontend:
          The encoder frontend.
      :param encoder:
          The encoder (i.e. context network).
      :param masker:
          The temporal/spatial feature masker.
      :param quantizer:
          The quantizer to discretize context network targets.
      :param final_dim:
          The dimensionality of the final projection that is applied to
          context network outputs and quantized targets.
      :param final_proj_bias:
          If ``True``, the final projection learns an additive bias.
      :param num_distractors:
          The number of distractors to use in contrastive prediction.
      :param logit_temp:
          The temperature to divide logits by.
      :param diversity_loss_weight:
          The weight of diversity in loss computation.
      """
      super().__init__()
  
      model_dim = encoder.model_dim
  
      self.model_dim = model_dim
  
      self.encoder_frontend = encoder_frontend
      self.encoder = encoder
  
      self.masker = masker
  
      if quantizer.input_dim != encoder_frontend.feature_dim:
          raise ValueError(
              f"`input_dim` of `quantizer` and `feature_dim` of `encoder_frontend` must be equal, but are {quantizer.input_dim} and {encoder_frontend.feature_dim} instead."
          )
  
      self.quantizer = quantizer
  
      self.final_proj = Linear(
          model_dim,
          final_dim,
          final_proj_bias,
          device=device,
          dtype=dtype,
      )
  
      self.final_target_proj = Linear(
          self.quantizer.output_dim,
          final_dim,
          bias=True,
          device=device,
          dtype=dtype,
      )
  
      self.num_distractors = num_distractors
      self.logit_temp = logit_temp
      self.diversity_loss_weight = diversity_loss_weight
  
imports: from __future__ import annotations
  from dataclasses import dataclass
  from typing import Optional, Tuple
  import torch
  from torch import Tensor
  from torch.nn import Module
  from torch.nn.functional import cross_entropy
  from fairseq2.models.sequence import SequenceBatch
  from fairseq2.models.wav2vec2.frontend import Wav2Vec2Frontend
  from fairseq2.models.wav2vec2.masker import Wav2Vec2Masker, extract_masked_elements
  from fairseq2.models.wav2vec2.vector_quantizer import VectorQuantizer, VectorQuantizerOutput
  from fairseq2.nn.ops import repeat_interleave
  from fairseq2.nn.padding import PaddingMask
  from fairseq2.nn.projection import Linear
  from fairseq2.nn.transformer import TransformerEncoder
  from fairseq2.typing import DataType, Device
label_desc: Use image node_id 1 to create a new Wav2Vec2Model object from inherited base classes: Module with example: obj = Wav2Vec2Model(encoder_frontend, encoder, masker, quantizer, final_dim)