code: def test_dnn_beamformer(
      use_frontend, use_beamformer, bnmask, num_spkrs, m_str
  ):
      bs = 4
      m = importlib.import_module(m_str)
      const = 1e-4
      numpy.random.seed(1)
  
      args = make_arg(
          use_frontend=use_frontend,
          use_beamformer=use_beamformer,
          bnmask=bnmask,
          num_spkrs=num_spkrs,
      )
      model = m.E2E(257, 5, args)
      beamformer = model.frontend.beamformer
      mask_estimator = beamformer.mask
  
      if "pytorch" in m_str:
          init_torch_weight_const(model, const)
      else:
          init_chainer_weight_const(model, const)
  
      # STFT feature
      feat_real = torch.from_numpy(
          numpy.random.uniform(size=(bs, 100, 2, 257))
      ).float()
      feat_imag = torch.from_numpy(
          numpy.random.uniform(size=(bs, 100, 2, 257))
      ).float()
      feat = m.to_torch_tensor({"real": feat_real, "imag": feat_imag})
      ilens = torch.tensor([100] * bs).long()
  
      # dnn_beamformer
      enhanced, ilens, mask_speeches = beamformer(feat, ilens)
      assert bnmask == len(mask_speeches)
      assert (bnmask - 1) == len(enhanced)
  
      # beamforming by hand
      feat = feat.permute(0, 3, 2, 1)
      masks, _ = mask_estimator(feat, ilens)
      mask_speech1, mask_speech2, mask_noise = masks
  
      b = importlib.import_module("espnet2.enh.layers.beamformer")
  
      psd_speech1 = b.get_power_spectral_density_matrix(
          feat, mask_speech1
      )
      psd_speech2 = b.get_power_spectral_density_matrix(
          feat, mask_speech2
      )
      psd_noise = b.get_power_spectral_density_matrix(feat, mask_noise)
  
      u1 = torch.zeros(
          *(feat.size()[:-3] + (feat.size(-2),)), device=feat.device
      )
      u1[..., args.ref_channel].fill_(1)
      u2 = torch.zeros(
          *(feat.size()[:-3] + (feat.size(-2),)), device=feat.device
      )
      u2[..., args.ref_channel].fill_(1)
  
      ws1 = b.get_mvdr_vector(psd_speech1, psd_speech2 + psd_noise, u1)
      ws2 = b.get_mvdr_vector(psd_speech2, psd_speech1 + psd_noise, u2)
  
      enhanced1 = b.apply_beamforming_vector(ws1, feat).transpose(
          -1, -2
      )
      enhanced2 = b.apply_beamforming_vector(ws2, feat).transpose(
          -1, -2
      )
  
      torch.testing.assert_close(enhanced1.real, enhanced[0].real)
      torch.testing.assert_close(enhanced2.real, enhanced[1].real)
      torch.testing.assert_close(enhanced1.imag, enhanced[0].imag)
      torch.testing.assert_close(enhanced2.imag, enhanced[1].imag)
  
file_path: espnet/test/test_multi_spkrs.py
imports: import argparse
  import importlib
  import re
  import numpy
  import pytest
  import torch
label_desc: Use image node_id 6 for calling a global function with example usage: test_dnn_beamformer(use_frontend, use_beamformer, bnmask, num_spkrs, m_str) without return types