class_docstr: Target Speaker Extraction Frontend model
class_docstr_tok: ["Target","Speaker","Extraction","Frontend","model"]
code: def __init__(
      self,
      encoder: AbsEncoder,
      extractor: AbsExtractor,
      decoder: AbsDecoder,
      loss_wrappers: List[AbsLossWrapper],
      num_spk: int = 1,
      flexible_numspk: bool = False,
      share_encoder: bool = True,
      extract_feats_in_collect_stats: bool = False,
  ):
      assert check_argument_types()
  
      super().__init__()
  
      self.encoder = encoder
      self.extractor = extractor
      self.decoder = decoder
      # Whether to share encoder for both mixture and enrollment
      self.share_encoder = share_encoder
      self.num_spk = num_spk
      # If True, self.num_spk is regarded as the MAXIMUM possible number of speakers
      self.flexible_numspk = flexible_numspk
  
      self.loss_wrappers = loss_wrappers
      names = [w.criterion.name for w in self.loss_wrappers]
      if len(set(names)) != len(names):
          raise ValueError(
              "Duplicated loss names are not allowed: {}".format(names)
          )
      for w in self.loss_wrappers:
          if getattr(w.criterion, "is_noise_loss", False):
              raise ValueError("is_noise_loss=True is not supported")
          elif getattr(w.criterion, "is_dereverb_loss", False):
              raise ValueError("is_dereverb_loss=True is not supported")
  
      # for multi-channel signal
      self.ref_channel = getattr(self.extractor, "ref_channel", None)
      if self.ref_channel is None:
          self.ref_channel = 0
  
      # Used in espnet2/tasks/abs_task.py for determining whether or not to do
      # collect_feats during collect stats (stage 5).
      self.extract_feats_in_collect_stats = (
          extract_feats_in_collect_stats
      )
  
imports: import contextlib
  from typing import Dict, List, Optional, OrderedDict, Tuple
  import torch
  from typeguard import check_argument_types
  from espnet2.enh.decoder.abs_decoder import AbsDecoder
  from espnet2.enh.encoder.abs_encoder import AbsEncoder
  from espnet2.enh.extractor.abs_extractor import AbsExtractor
  from espnet2.enh.loss.criterions.tf_domain import FrequencyDomainLoss
  from espnet2.enh.loss.criterions.time_domain import TimeDomainLoss
  from espnet2.enh.loss.wrappers.abs_wrapper import AbsLossWrapper
  from espnet2.torch_utils.device_funcs import force_gatherable
  from espnet2.train.abs_espnet_model import AbsESPnetModel
label_desc: Use image node_id 1 to create a new ESPnetExtractionModel object from inherited base classes: AbsESPnetModel with example: obj = ESPnetExtractionModel(encoder, extractor, decoder, loss_wrappers, num_spk, flexible_numspk, share_encoder, extract_feats_in_collect_stats)