class_docstr: Speech enhancement or separation Frontend model
code: def _get_speech_masks(
      self,
      criterion,
      feature_mix,
      noise_ref,
      speech_ref,
      speech_pre,
      ilens,
      others,
      fs=None,
  ):
      if noise_ref is not None:
          noise_spec = self.encoder(sum(noise_ref), ilens, fs=fs)[0]
      else:
          noise_spec = None
      masks_ref = criterion.create_mask_label(
          feature_mix,
          [self.encoder(sr, ilens, fs=fs)[0] for sr in speech_ref],
          noise_spec=noise_spec,
      )
      if "mask_spk1" in others:
          masks_pre = [
              others["mask_spk{}".format(spk + 1)]
              for spk in range(self.num_spk)
              if "mask_spk{}".format(spk + 1) in others
          ]
      else:
          masks_pre = criterion.create_mask_label(
              feature_mix,
              [self.encoder(sp, ilens, fs=fs)[0] for sp in speech_pre],
              noise_spec=noise_spec,
          )
      return masks_ref, masks_pre
  
imports: import contextlib
  from typing import Dict, List, Optional, OrderedDict, Tuple
  import numpy
  import torch
  from packaging.version import parse
  from typeguard import check_argument_types
  from espnet2.diar.layers.abs_mask import AbsMask
  from espnet2.enh.decoder.abs_decoder import AbsDecoder
  from espnet2.enh.encoder.abs_encoder import AbsEncoder
  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.enh.separator.abs_separator import AbsSeparator
  from espnet2.enh.separator.dan_separator import DANSeparator
  from espnet2.enh.separator.uses_separator import USESSeparator
  from espnet2.torch_utils.device_funcs import force_gatherable
  from espnet2.train.abs_espnet_model import AbsESPnetModel
label_desc: Use image node_id 8 for calling the ESPnetEnhancementModel obj's underlying member method code with example usage: obj._get_speech_masks(criterion, feature_mix, noise_ref, speech_ref, speech_pre, ilens, others, fs) and returns: masks_ref,  masks_pre