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","`","."]
code: def _sample_distractors(self, targets: Tensor) -> Tensor:
      batch_size, seq_len, model_dim = targets.shape
  
      device = targets.device
  
      # (N, S, M) -> (N x S, M)
      targets = targets.view(-1, model_dim)
  
      # (S)
      indices = torch.arange(seq_len, device=device)
  
      # (S) -> (S x L)
      indices = repeat_interleave(
          indices, dim=0, repeat=self.num_distractors
      )
  
      # (N, S x L)
      rand_indices = torch.randint(
          low=0,
          high=seq_len - 1,
          size=(batch_size, seq_len * self.num_distractors),
          device=device,
      )
  
      # (N, S x L)
      rand_indices[rand_indices >= indices] += 1
  
      # (N, 1)
      k = torch.arange(batch_size, device=device).unsqueeze(1) * seq_len
  
      # (N, S x L)
      rand_indices += k
  
      # (N, S x L) -> (N x S x L)
      rand_indices = rand_indices.view(-1)
  
      # (N x S x L, M)
      distractors = targets[rand_indices]
  
      # (N x S x L) -> (N, S, L, M)
      distractors = distractors.view(
          batch_size, seq_len, self.num_distractors, model_dim
      )
  
      return distractors
  
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 5 for calling the Wav2Vec2Model obj's underlying member method code with example usage: obj._sample_distractors(targets) and returns: distractors