class_docstr: Speaker embedding extraction model.
  Core model for diverse speaker-related tasks (e.g., verification, open-set
  identification, diarization)
  
  The model architecture comprises mainly 'encoder', 'pooling', and
  'projector'.
  In common speaker recognition field, the combination of three would be
  usually named as 'speaker_encoder' (or speaker embedding extractor).
  We splitted it into three for flexibility in future extensions:
    - 'encoder'   : extract frame-level speaker embeddings.
    - 'pooling'   : aggregate into single utterance-level embedding.
    - 'projector' : (optional) additional processing (e.g., one fully-
                    connected layer) to derive speaker embedding.
  
  Possibly, in the future, 'pooling' and/or 'projector' can be integrated as
  a 'decoder', depending on the extension for joint usage of different tasks
  (e.g., ASR, SE, target speaker extraction).
docstr: Feed-forward through encoder layers and aggregate into utterance-level
  feature.
  
  Args:
      speech: (Batch, samples)
      speech_lengths: (Batch,)
      extract_embd: a flag which doesn't go through the classification
          head when set True
      spk_labels: (Batch, )
      one-hot speaker labels used in the train phase
      task_tokens: (Batch, )
      task tokens used in case of token-based trainings
docstr_tok: ["Feed-forward","through","encoder","layers","and","aggregate","into","utterance-level","feature",".","Args",":","speech",":","(","Batch",",","samples",")","speech_lengths",":","(","Batch",",",")","extract_embd",":","a","flag","which","does","n't","go","through","the","classification","head","when","set","True","spk_labels",":","(","Batch",",",")","one-hot","speaker","labels","used","in","the","train","phase","task_tokens",":","(","Batch",",",")","task","tokens","used","in","case","of","token-based","trainings"]
code: def forward(
      self,
      speech: torch.Tensor,
      spk_labels: torch.Tensor = None,
      task_tokens: torch.Tensor = None,
      extract_embd: bool = False,
      **kwargs,
  ) -> Tuple[torch.Tensor, Dict[str, torch.Tensor], torch.Tensor]:
      """
      Feed-forward through encoder layers and aggregate into utterance-level
      feature.
  
      Args:
          speech: (Batch, samples)
          speech_lengths: (Batch,)
          extract_embd: a flag which doesn't go through the classification
              head when set True
          spk_labels: (Batch, )
          one-hot speaker labels used in the train phase
          task_tokens: (Batch, )
          task tokens used in case of token-based trainings
      """
      if spk_labels is not None:
          assert speech.shape[0] == spk_labels.shape[0], (
              speech.shape,
              spk_labels.shape,
          )
      if task_tokens is not None:
          assert speech.shape[0] == task_tokens.shape[0], (
              speech.shape,
              task_tokens.shape,
          )
      batch_size = speech.shape[0]
  
      # 1. extract low-level feats (e.g., mel-spectrogram or MFCC)
      # Will do nothing for raw waveform-based models (e.g., RawNets)
      feats, _ = self.extract_feats(speech, None)
  
      frame_level_feats = self.encode_frame(feats)
  
      # 2. aggregation into utterance-level
      utt_level_feat = self.pooling(frame_level_feats, task_tokens)
  
      # 3. (optionally) go through further projection(s)
      spk_embd = self.project_spk_embd(utt_level_feat)
  
      if extract_embd:
          return spk_embd
  
      # 4. calculate loss
      assert (
          spk_labels is not None
      ), "spk_labels is None, cannot compute loss"
      loss = self.loss(spk_embd, spk_labels.squeeze())
  
      stats = dict(loss=loss.detach())
  
      loss, stats, weight = force_gatherable(
          (loss, stats, batch_size), loss.device
      )
      return loss, stats, weight
  
imports: from typing import Dict, Optional, Tuple, Union
  import torch
  from typeguard import check_argument_types
  from espnet2.asr.encoder.abs_encoder import AbsEncoder
  from espnet2.asr.frontend.abs_frontend import AbsFrontend
  from espnet2.asr.specaug.abs_specaug import AbsSpecAug
  from espnet2.layers.abs_normalize import AbsNormalize
  from espnet2.spk.loss.aamsoftmax import AAMSoftmax
  from espnet2.spk.loss.abs_loss import AbsLoss
  from espnet2.spk.pooling.abs_pooling import AbsPooling
  from espnet2.spk.projector.abs_projector import AbsProjector
  from espnet2.torch_utils.device_funcs import force_gatherable
  from espnet2.train.abs_espnet_model import AbsESPnetModel
label_desc: Use image node_id 2 for calling the ESPnetSpeakerModel obj's underlying member method code with example usage: obj.forward(speech, spk_labels, task_tokens, extract_embd) and returns: loss,  stats,  weight, spk_embd