code: def test_forward_with_beamformer_net(
      training,
      mask_type,
      loss_type,
      num_spk,
      use_builtin_complex,
      loss_wrappers,
  ):
      # Skip some testing cases
      if not loss_type.startswith("mask") and mask_type != "IBM":
          # `mask_type` has no effect when `loss_type` is not "mask..."
          return
      if not is_torch_1_9_plus and use_builtin_complex:
          # builtin complex support is only well supported in PyTorch 1.9+
          return
      if is_torch_1_12_1_plus and not use_builtin_complex:
          # non-builtin complex support is deprecated in PyTorch 1.12.1+
          return
  
      ch = 3
      inputs = random_speech[..., :ch].float()
      ilens = torch.LongTensor([16, 12])
      speech_refs = [
          torch.randn(2, 16, dtype=torch.float)
          for spk in range(num_spk)
      ]
      noise_ref1 = torch.randn(2, 16, ch, dtype=torch.float)
      dereverb_ref1 = torch.randn(2, 16, ch, dtype=torch.float)
      encoder = STFTEncoder(
          n_fft=8, hop_length=2, use_builtin_complex=use_builtin_complex
      )
      decoder = STFTDecoder(n_fft=8, hop_length=2)
  
      beamformer = NeuralBeamformer(
          input_dim=5,
          loss_type=loss_type,
          num_spk=num_spk,
          use_wpe=True,
          wlayers=2,
          wunits=2,
          wprojs=2,
          use_dnn_mask_for_wpe=True,
          multi_source_wpe=True,
          use_beamformer=True,
          blayers=2,
          bunits=2,
          bprojs=2,
          badim=2,
          ref_channel=0,
          use_noise_mask=False,
          beamformer_type="mvdr_souden",
          use_torchaudio_api=is_torch_1_12_1_plus,
      )
      enh_model = ESPnetEnhancementModel(
          encoder=encoder,
          decoder=decoder,
          separator=beamformer,
          mask_module=None,
          loss_type=loss_type,
          mask_type=mask_type,
          loss_wrappers=loss_wrappers,
      )
      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)
          },
          "dereverb_ref1": dereverb_ref1,
      }
      loss, stats, weight = enh_model(**kwargs)
      if mask_type in ("IBM", "IRM"):
          loss, stats, weight = enh_model(
              **kwargs, noise_ref1=noise_ref1
          )
  
imports: import pytest
  import torch
  from packaging.version import parse
  from espnet2.enh.decoder.conv_decoder import ConvDecoder
  from espnet2.enh.decoder.null_decoder import NullDecoder
  from espnet2.enh.decoder.stft_decoder import STFTDecoder
  from espnet2.enh.encoder.conv_encoder import ConvEncoder
  from espnet2.enh.encoder.null_encoder import NullEncoder
  from espnet2.enh.encoder.stft_encoder import STFTEncoder
  from espnet2.enh.espnet_model import ESPnetEnhancementModel
  from espnet2.enh.loss.criterions.tf_domain import FrequencyDomainL1, FrequencyDomainMSE
  from espnet2.enh.loss.criterions.time_domain import SISNRLoss
  from espnet2.enh.loss.wrappers.fixed_order import FixedOrderSolver
  from espnet2.enh.loss.wrappers.multilayer_pit_solver import MultiLayerPITSolver
  from espnet2.enh.loss.wrappers.pit_solver import PITSolver
  from espnet2.enh.separator.conformer_separator import ConformerSeparator
  from espnet2.enh.separator.dc_crn_separator import DC_CRNSeparator
  from espnet2.enh.separator.dccrn_separator import DCCRNSeparator
  from espnet2.enh.separator.dprnn_separator import DPRNNSeparator
  from espnet2.enh.separator.dptnet_separator import DPTNetSeparator
  from espnet2.enh.separator.ineube_separator import iNeuBe
  from espnet2.enh.separator.neural_beamformer import NeuralBeamformer
  from espnet2.enh.separator.rnn_separator import RNNSeparator
  from espnet2.enh.separator.svoice_separator import SVoiceSeparator
  from espnet2.enh.separator.tcn_separator import TCNSeparator
  from espnet2.enh.separator.tfgridnet_separator import TFGridNet
  from espnet2.enh.separator.tfgridnetv2_separator import TFGridNetV2
  from espnet2.enh.separator.transformer_separator import TransformerSeparator
  from espnet2.enh.separator.uses_separator import USESSeparator
label_desc: Use image node_id 11 for calling a global function with example usage: test_forward_with_beamformer_net(training, mask_type, loss_type, num_spk, use_builtin_complex, loss_wrappers) without return types