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: Run the encoder frontend in pretraining mode.
  
  :param seqs:
      The sequences to process. *Shape:* :math:`(N,S,*)`, where :math:`N`
      is the batch size, :math:`S` is the sequence length, and :math:`*`
      is any number of sequence-specific dimensions including none.
  :param padding_mask:
      The padding mask of ``seqs``. *Shape:* :math:`(N,S)`, where :math:`N`
      is the batch size and :math:`S` is the sequence length.
  
  :returns:
      - The processed sequences to pass to the Transformer encoder.
        *Shape:* :math:`(N,S_{out},M)`, where :math:`N` is the batch size,
        :math:`S_{out}` is the output sequence length, and :math:`M` is
        the dimensionality of the model.
      - The padding mask of the processed sequences. *Shape:*
        :math:`(N,S_{out})`, where :math:`N` is the batch size and
        :math:`S_{out}` is the output sequence length.
      - The non-quantized context network targets that have been extracted
        from the input sequences. *Shape:* :math:`(N,S_{msk},M)`, where
        :math:`N` is the batch size, :math:`S_{msk}` is the masked
        sequence length, and :math:`M` is the dimensionality of the model.
      - The temporal mask that has been applied to extract the context
        network targets. *Shape:* :math:`(N,S_{out})`, where :math:`N` is
        the batch size and :math`S_{out}` is the output sequence length.
docstr_tok: ["Run","the","encoder","frontend","in","pretraining","mode",".",":","param","seqs",":","The","sequences","to","process",".","*","Shape",":","*",":","math",":","`","(","N",",","S",",","*",")","`",",","where",":","math",":","`","N","`","is","the","batch","size",",",":","math",":","`","S","`","is","the","sequence","length",",","and",":","math",":","`","*","`","is","any","number","of","sequence-specific","dimensions","including","none",".",":","param","padding_mask",":","The","padding","mask","of","``","seqs","``",".","*","Shape",":","*",":","math",":","`","(","N",",","S",")","`",",","where",":","math",":","`","N","`","is","the","batch","size","and",":","math",":","`","S","`","is","the","sequence","length",".",":","returns",":","-","The","processed","sequences","to","pass","to","the","Transformer","encoder",".","*","Shape",":","*",":","math",":","`","(","N",",","S_","{","out","}",",","M",")","`",",","where",":","math",":","`","N","`","is","the","batch","size",",",":","math",":","`","S_","{","out","}","`","is","the","output","sequence","length",",","and",":","math",":","`","M","`","is","the","dimensionality","of","the","model",".","-","The","padding","mask","of","the","processed","sequences",".","*","Shape",":","*",":","math",":","`","(","N",",","S_","{","out","}",")","`",",","where",":","math",":","`","N","`","is","the","batch","size","and",":","math",":","`","S_","{","out","}","`","is","the","output","sequence","length",".","-","The","non-quantized","context","network","targets","that","have","been","extracted","from","the","input","sequences",".","*","Shape",":","*",":","math",":","`","(","N",",","S_","{","msk","}",",","M",")","`",",","where",":","math",":","`","N","`","is","the","batch","size",",",":","math",":","`","S_","{","msk","}","`","is","the","masked","sequence","length",",","and",":","math",":","`","M","`","is","the","dimensionality","of","the","model",".","-","The","temporal","mask","that","has","been","applied","to","extract","the","context","network","targets",".","*","Shape",":","*",":","math",":","`","(","N",",","S_","{","out","}",")","`",",","where",":","math",":","`","N","`","is","the","batch","size","and",":","math","`","S_","{","out","}","`","is","the","output","sequence","length","."]
code: def run_frontend(
      self, seqs: Tensor, padding_mask: Optional[PaddingMask]
  ) -> Tuple[Tensor, Optional[PaddingMask], Tensor, Tensor]:
      """Run the encoder frontend in pretraining mode.
  
      :param seqs:
          The sequences to process. *Shape:* :math:`(N,S,*)`, where :math:`N`
          is the batch size, :math:`S` is the sequence length, and :math:`*`
          is any number of sequence-specific dimensions including none.
      :param padding_mask:
          The padding mask of ``seqs``. *Shape:* :math:`(N,S)`, where :math:`N`
          is the batch size and :math:`S` is the sequence length.
  
      :returns:
          - The processed sequences to pass to the Transformer encoder.
            *Shape:* :math:`(N,S_{out},M)`, where :math:`N` is the batch size,
            :math:`S_{out}` is the output sequence length, and :math:`M` is
            the dimensionality of the model.
          - The padding mask of the processed sequences. *Shape:*
            :math:`(N,S_{out})`, where :math:`N` is the batch size and
            :math:`S_{out}` is the output sequence length.
          - The non-quantized context network targets that have been extracted
            from the input sequences. *Shape:* :math:`(N,S_{msk},M)`, where
            :math:`N` is the batch size, :math:`S_{msk}` is the masked
            sequence length, and :math:`M` is the dimensionality of the model.
          - The temporal mask that has been applied to extract the context
            network targets. *Shape:* :math:`(N,S_{out})`, where :math:`N` is
            the batch size and :math`S_{out}` is the output sequence length.
      """
      frontend = self.encoder_frontend
  
      seqs, padding_mask = frontend.extract_features(seqs, padding_mask)
  
      # We use the extracted features as context network targets after masking
      # and quantization.
      targets = seqs.clone().detach()
  
      if frontend.first_pass_dropout is not None:
          targets = frontend.first_pass_dropout(targets)
  
      seqs, padding_mask, temporal_mask = frontend.process_features(
          seqs, padding_mask, self.masker
      )
  
      assert temporal_mask is not None
  
      targets = extract_masked_elements(targets, temporal_mask)
  
      return seqs, padding_mask, targets, temporal_mask
  
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 3 for calling the Wav2Vec2Model obj's underlying member method code with example usage: obj.run_frontend(seqs, padding_mask) and returns: seqs,  padding_mask,  targets,  temporal_mask