class_docstr: Target Speaker Extraction Frontend model
class_docstr_tok: ["Target","Speaker","Extraction","Frontend","model"]
code: def forward_loss(
      self,
      speech_ref,
      speech_mix,
      speech_lengths,
  ) -> Tuple[torch.Tensor, Dict[str, torch.Tensor], torch.Tensor]:
      feature_mix, flens = self.encoder(speech_mix, speech_lengths)
      feature_ref, flens = self.encoder(speech_ref[0], speech_lengths)
  
      stats = {}
      loss = self.diffusion(
          feature_ref=feature_ref, feature_mix=feature_mix
      )
      stats["loss"] = loss.detach()
      batch_size = speech_ref[0].shape[0]
      loss, stats, weight = force_gatherable(
          (loss, stats, batch_size), loss.device
      )
      return loss, stats, weight
  
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.diffusion.abs_diffusion import AbsDiffusion
  from espnet2.enh.encoder.abs_encoder import AbsEncoder
  from espnet2.enh.espnet_model import ESPnetEnhancementModel
  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 4 for calling the ESPnetDiffusionModel obj's underlying member method code with example usage: obj.forward_loss(speech_ref, speech_mix, speech_lengths) and returns: loss,  stats,  weight