class_docstr: DNN mask based Beamformer.
  
  Citation:
      Multichannel End-to-end Speech Recognition; T. Ochiai et al., 2017;
      http://proceedings.mlr.press/v70/ochiai17a/ochiai17a.pdf
class_docstr_tok: ["DNN","mask","based","Beamformer",".","Citation",":","Multichannel","End-to-end","Speech","Recognition",";","T.","Ochiai","et","al.",",","2017",";","http",":","\/\/proceedings.mlr.press\/v70\/ochiai17a\/ochiai17a.pdf"]
code: def __init__(
      self,
      bidim,
      btype: str = "blstmp",
      blayers: int = 3,
      bunits: int = 300,
      bprojs: int = 320,
      num_spk: int = 1,
      use_noise_mask: bool = True,
      nonlinear: str = "sigmoid",
      dropout_rate: float = 0.0,
      badim: int = 320,
      ref_channel: int = -1,
      beamformer_type: str = "mvdr_souden",
      rtf_iterations: int = 2,
      mwf_mu: float = 1.0,
      eps: float = 1e-6,
      diagonal_loading: bool = True,
      diag_eps: float = 1e-7,
      mask_flooring: bool = False,
      flooring_thres: float = 1e-6,
      use_torch_solver: bool = True,
      # False to use old APIs; True to use torchaudio-based new APIs
      use_torchaudio_api: bool = False,
      # only for WPD beamformer
      btaps: int = 5,
      bdelay: int = 3,
  ):
      super().__init__()
      bnmask = num_spk + 1 if use_noise_mask else num_spk
      self.mask = MaskEstimator(
          btype,
          bidim,
          blayers,
          bunits,
          bprojs,
          dropout_rate,
          nmask=bnmask,
          nonlinear=nonlinear,
      )
      self.ref = (
          AttentionReference(bidim, badim, eps=eps)
          if ref_channel < 0
          else None
      )
      self.ref_channel = ref_channel
  
      self.use_noise_mask = use_noise_mask
      assert num_spk >= 1, num_spk
      self.num_spk = num_spk
      self.nmask = bnmask
  
      if beamformer_type not in BEAMFORMER_TYPES:
          raise ValueError(
              "Not supporting beamformer_type=%s" % beamformer_type
          )
      if (
          beamformer_type == "mvdr_souden"
          or not beamformer_type.endswith("_souden")
      ) and not use_noise_mask:
          if num_spk == 1:
              logging.warning(
                  "Initializing %s beamformer without noise mask "
                  "estimator (single-speaker case)"
                  % beamformer_type.upper()
              )
              logging.warning(
                  "(1 - speech_mask) will be used for estimating noise "
                  "PSD in %s beamformer!" % beamformer_type.upper()
              )
          else:
              logging.warning(
                  "Initializing %s beamformer without noise mask "
                  "estimator (multi-speaker case)"
                  % beamformer_type.upper()
              )
              logging.warning(
                  "Interference speech masks will be used for estimating "
                  "noise PSD in %s beamformer!"
                  % beamformer_type.upper()
              )
  
      self.beamformer_type = beamformer_type
      if not beamformer_type.endswith("_souden"):
          assert rtf_iterations >= 2, rtf_iterations
      # number of iterations in power method for estimating the RTF
      self.rtf_iterations = rtf_iterations
      # noise suppression weight in SDW-MWF
      self.mwf_mu = mwf_mu
  
      assert btaps >= 0 and bdelay >= 0, (btaps, bdelay)
      self.btaps = btaps
      self.bdelay = bdelay if self.btaps > 0 else 1
      self.eps = eps
      self.diagonal_loading = diagonal_loading
      self.diag_eps = diag_eps
      self.mask_flooring = mask_flooring
      self.flooring_thres = flooring_thres
      self.use_torch_solver = use_torch_solver
      if not use_torch_solver:
          logging.warning(
              "The `use_torch_solver` argument has been deprecated. "
              "Now it will always be true in DNN_Beamformer"
          )
  
      if use_torchaudio_api and is_torch_1_12_1_plus:
          self.bf_func = bf_v2
      else:
          self.bf_func = bf_v1
  
file_path: espnet/espnet2/enh/layers/dnn_beamformer.py
imports: import logging
  from typing import List, Optional, Tuple, Union
  import torch
  from packaging.version import parse
  from torch.nn import functional
  from torch_complex.tensor import ComplexTensor
  import espnet2.enh.layers.beamformer
  import espnet2.enh.layers.beamformer_th
  from espnet2.enh.layers.complex_utils import stack, to_double, to_float
  from espnet2.enh.layers.mask_estimator import MaskEstimator
label_desc: Use image node_id 1 to create a new DNN_Beamformer object from inherited base classes: torch.nn with example: obj = DNN_Beamformer(bidim, btype, blayers, bunits, bprojs, num_spk, use_noise_mask, nonlinear, dropout_rate, badim, ref_channel, beamformer_type, rtf_iterations, mwf_mu, eps, diagonal_loading, diag_eps, mask_flooring, flooring_thres, use_torch_solver, use_torchaudio_api, btaps, bdelay)