code: def test_beamformer_net_consistency(
      num_spk, use_noise_mask, beamformer_type
  ):
      if beamformer_type in (
          "lcmv",
          "lcmp",
          "wlcmp",
          "mvdr_tfs",
          "mvdr_tfs_souden",
      ):
          # skip these beamformers as they require real multi-speaker data to obtain
          # consistent results
          return
  
      torch.random.manual_seed(0)
      ch = 2
      inputs = random_speech[..., :ch].float().repeat(1, 5, 1)
      ilens = torch.LongTensor([80, 60])
  
      stft1 = STFTEncoder(
          n_fft=8, hop_length=2, use_builtin_complex=True
      )
      stft2 = STFTEncoder(
          n_fft=8, hop_length=2, use_builtin_complex=False
      )
      args = dict(
          num_spk=num_spk,
          use_wpe=False,
          taps=2,
          delay=3,
          use_beamformer=True,
          blayers=2,
          bunits=2,
          bprojs=2,
          badim=2,
          use_noise_mask=use_noise_mask,
          beamformer_type=beamformer_type,
          diagonal_loading=True,
          mask_flooring=True,
          use_torch_solver=True,
      )
      model1 = NeuralBeamformer(
          stft1.output_dim, use_torchaudio_api=True, **args
      )
      model2 = NeuralBeamformer(
          stft2.output_dim, use_torchaudio_api=False, **args
      )
      model1.eval()
      model2.eval()
      models = [model1, model2]
      input_spectrum1, flens = stft1(inputs, ilens)
      input_spectrum2 = stft2(inputs, ilens)[0]
      inputs = [input_spectrum1, input_spectrum2]
  
      specs = [
          model(input_spectrum, flens)[0]
          for model, input_spectrum in zip(models, inputs)
      ]
      for spk in range(num_spk):
          np.testing.assert_allclose(
              *[s[spk].detach().numpy() for s in specs], atol=1e-1
          )
  
file_path: espnet/test/espnet2/enh/separator/test_beamformer.py
imports: import numpy
  import pytest
  import torch
  from packaging.version import parse
  from espnet2.enh.encoder.stft_encoder import STFTEncoder
  from espnet2.enh.layers.complex_utils import is_torch_complex_tensor
  from espnet2.enh.layers.dnn_beamformer import BEAMFORMER_TYPES
  from espnet2.enh.separator.neural_beamformer import NeuralBeamformer
label_desc: Use image node_id 4 for calling a global function with example usage: test_beamformer_net_consistency(num_spk, use_noise_mask, beamformer_type) without return types