code: def test_criterion_behavior_validation(
      encoder, decoder, training, num_spk, loss_wrapper
  ):
      inputs = torch.randn(2, 300)
      ilens = torch.LongTensor([300, 200])
      speech_refs = [
          torch.randn(2, 300).float(),
          torch.randn(2, 300).float(),
      ]
      enroll_refs = [
          torch.randn(2, 400).float(),
          torch.randn(2, 400).float(),
      ]
      aux_lens = [
          torch.LongTensor([400, 300]),
          torch.LongTensor([400, 350]),
      ]
      if num_spk == 1:
          speech_refs = speech_refs[:1]
          enroll_refs = enroll_refs[:1]
          aux_lens = aux_lens[:1]
      enh_model = ESPnetExtractionModel(
          encoder=encoder,
          extractor=td_speakerbeam_extractor,
          decoder=decoder,
          loss_wrappers=[loss_wrapper],
          num_spk=num_spk,
          share_encoder=True,
      )
  
      if training:
          enh_model.train()
      else:
          enh_model.eval()
  
      kwargs = {
          "speech_mix": inputs,
          "speech_mix_lengths": ilens,
          **{
              "speech_ref{}".format(i + 1): speech_refs[i]
              for i in range(num_spk)
          },
          **{
              "enroll_ref{}".format(i + 1): enroll_refs[i]
              for i in range(num_spk)
          },
          **{
              "enroll_ref{}_lengths".format(i + 1): aux_lens[i]
              for i in range(num_spk)
          },
      }
  
      if training:
          loss, stats, weight = enh_model(**kwargs)
      else:
          loss, stats, weight = enh_model(**kwargs)
  
file_path: espnet/test/espnet2/enh/test_espnet_model_tse.py
imports: import pytest
  import torch
  from packaging.version import parse
  from espnet2.enh.decoder.conv_decoder import ConvDecoder
  from espnet2.enh.decoder.stft_decoder import STFTDecoder
  from espnet2.enh.encoder.conv_encoder import ConvEncoder
  from espnet2.enh.encoder.stft_encoder import STFTEncoder
  from espnet2.enh.espnet_model_tse import ESPnetExtractionModel
  from espnet2.enh.extractor.td_speakerbeam_extractor import TDSpeakerBeamExtractor
  from espnet2.enh.loss.criterions.tf_domain import FrequencyDomainMSE
  from espnet2.enh.loss.criterions.time_domain import SISNRLoss
  from espnet2.enh.loss.wrappers.fixed_order import FixedOrderSolver
  from espnet2.enh.loss.wrappers.pit_solver import PITSolver
label_desc: Use image node_id 1 for calling a global function with example usage: test_criterion_behavior_validation(encoder, decoder, training, num_spk, loss_wrapper) without return types