docstr: DCCRN separator.
  
  Args:
      input_dim (int): input dimension。
      num_spk (int, optional): number of speakers. Defaults to 1.
      rnn_layer (int, optional): number of lstm layers in the crn. Defaults to 2.
      rnn_units (int, optional): rnn units. Defaults to 128.
      masking_mode (str, optional): usage of the estimated mask. Defaults to "E".
      use_clstm (bool, optional): whether use complex LSTM. Defaults to False.
      bidirectional (bool, optional): whether use BLSTM. Defaults to False.
      use_cbn (bool, optional): whether use complex BN. Defaults to False.
      kernel_size (int, optional): convolution kernel size. Defaults to 5.
      kernel_num (list, optional): output dimension of each layer of the encoder.
      use_builtin_complex (bool, optional): torch.complex if True,
                                          else ComplexTensor.
      use_noise_mask (bool, optional): whether to estimate the mask of noise.
docstr_tok: ["DCCRN","separator",".","Args",":","input_dim","(","int",")",":","input","dimension\u3002","num_spk","(","int",",","optional",")",":","number","of","speakers",".","Defaults","to","1.","rnn_layer","(","int",",","optional",")",":","number","of","lstm","layers","in","the","crn",".","Defaults","to","2.","rnn_units","(","int",",","optional",")",":","rnn","units",".","Defaults","to","128.","masking_mode","(","str",",","optional",")",":","usage","of","the","estimated","mask",".","Defaults","to","``","E","''",".","use_clstm","(","bool",",","optional",")",":","whether","use","complex","LSTM",".","Defaults","to","False",".","bidirectional","(","bool",",","optional",")",":","whether","use","BLSTM",".","Defaults","to","False",".","use_cbn","(","bool",",","optional",")",":","whether","use","complex","BN",".","Defaults","to","False",".","kernel_size","(","int",",","optional",")",":","convolution","kernel","size",".","Defaults","to","5.","kernel_num","(","list",",","optional",")",":","output","dimension","of","each","layer","of","the","encoder",".","use_builtin_complex","(","bool",",","optional",")",":","torch.complex","if","True",",","else","ComplexTensor",".","use_noise_mask","(","bool",",","optional",")",":","whether","to","estimate","the","mask","of","noise","."]
code: def __init__(
      self,
      input_dim: int,
      num_spk: int = 1,
      rnn_layer: int = 2,
      rnn_units: int = 256,
      masking_mode: str = "E",
      use_clstm: bool = True,
      bidirectional: bool = False,
      use_cbn: bool = False,
      kernel_size: int = 5,
      kernel_num: List[int] = [32, 64, 128, 256, 256, 256],
      use_builtin_complex: bool = True,
      use_noise_mask: bool = False,
  ):
      """DCCRN separator.
  
      Args:
          input_dim (int): input dimension。
          num_spk (int, optional): number of speakers. Defaults to 1.
          rnn_layer (int, optional): number of lstm layers in the crn. Defaults to 2.
          rnn_units (int, optional): rnn units. Defaults to 128.
          masking_mode (str, optional): usage of the estimated mask. Defaults to "E".
          use_clstm (bool, optional): whether use complex LSTM. Defaults to False.
          bidirectional (bool, optional): whether use BLSTM. Defaults to False.
          use_cbn (bool, optional): whether use complex BN. Defaults to False.
          kernel_size (int, optional): convolution kernel size. Defaults to 5.
          kernel_num (list, optional): output dimension of each layer of the encoder.
          use_builtin_complex (bool, optional): torch.complex if True,
                                              else ComplexTensor.
          use_noise_mask (bool, optional): whether to estimate the mask of noise.
      """
      super().__init__()
      self.use_builtin_complex = use_builtin_complex
      self._num_spk = num_spk
      self.use_noise_mask = use_noise_mask
      self.predict_noise = use_noise_mask
      if masking_mode not in ["C", "E", "R"]:
          raise ValueError(
              "Unsupported masking mode: %s" % masking_mode
          )
      # Network config
      self.rnn_units = rnn_units
      self.hidden_layers = rnn_layer
      self.kernel_size = kernel_size
      self.kernel_num = [2] + kernel_num
      self.masking_mode = masking_mode
      self.use_clstm = use_clstm
  
      fac = 2 if bidirectional else 1
  
      self.encoder = nn.ModuleList()
      self.decoder = nn.ModuleList()
      for idx in range(len(self.kernel_num) - 1):
          self.encoder.append(
              nn.Sequential(
                  ComplexConv2d(
                      self.kernel_num[idx],
                      self.kernel_num[idx + 1],
                      kernel_size=(self.kernel_size, 2),
                      stride=(2, 1),
                      padding=(2, 1),
                  ),
                  nn.BatchNorm2d(self.kernel_num[idx + 1])
                  if not use_cbn
                  else ComplexBatchNorm(self.kernel_num[idx + 1]),
                  nn.PReLU(),
              )
          )
      hidden_dim = (
          input_dim - 1 + 2 ** (len(self.kernel_num) - 1) - 1
      ) // (2 ** (len(self.kernel_num) - 1))
      hidden_dim = hidden_dim if hidden_dim > 0 else 1
  
      if self.use_clstm:
          rnns = []
          for idx in range(rnn_layer):
              rnns.append(
                  NavieComplexLSTM(
                      input_size=hidden_dim * self.kernel_num[-1]
                      if idx == 0
                      else self.rnn_units * fac,
                      hidden_size=self.rnn_units,
                      bidirectional=bidirectional,
                      batch_first=False,
                      projection_dim=hidden_dim * self.kernel_num[-1]
                      if idx == rnn_layer - 1
                      else None,
                  )
              )
              self.enhance = nn.Sequential(*rnns)
      else:
          self.enhance = nn.LSTM(
              input_size=hidden_dim * self.kernel_num[-1],
              hidden_size=self.rnn_units,
              num_layers=2,
              dropout=0.0,
              bidirectional=bidirectional,
              batch_first=False,
          )
          self.tranform = nn.Linear(
              self.rnn_units * fac, hidden_dim * self.kernel_num[-1]
          )
  
      for idx in range(len(self.kernel_num) - 1, 0, -1):
          if idx != 1:
              self.decoder.append(
                  nn.Sequential(
                      ComplexConvTranspose2d(
                          self.kernel_num[idx] * 2,
                          self.kernel_num[idx - 1],
                          kernel_size=(self.kernel_size, 2),
                          stride=(2, 1),
                          padding=(2, 0),
                          output_padding=(1, 0),
                      ),
                      nn.BatchNorm2d(self.kernel_num[idx - 1])
                      if not use_cbn
                      else ComplexBatchNorm(self.kernel_num[idx - 1]),
                      nn.PReLU(),
                  )
              )
          else:
              self.decoder.append(
                  nn.Sequential(
                      ComplexConvTranspose2d(
                          self.kernel_num[idx] * 2,
                          self.kernel_num[idx - 1] * (self._num_spk + 1)
                          if self.use_noise_mask
                          else self.kernel_num[idx - 1] * self._num_spk,
                          kernel_size=(self.kernel_size, 2),
                          stride=(2, 1),
                          padding=(2, 0),
                          output_padding=(1, 0),
                      ),
                  )
              )
  
      self.flatten_parameters()
  
file_path: espnet/espnet2/enh/separator/dccrn_separator.py
imports: from collections import OrderedDict
  from typing import Dict, List, Optional, Tuple, Union
  import torch
  import torch.nn
  import torch.nn.functional
  from packaging.version import parse
  from torch_complex.tensor import ComplexTensor
  from espnet2.enh.layers.complexnn import ComplexBatchNorm, ComplexConv2d, ComplexConvTranspose2d, NavieComplexLSTM, complex_cat
  from espnet2.enh.separator.abs_separator import AbsSeparator
label_desc: Use image node_id 1 to create a new DCCRNSeparator object from inherited base classes: AbsSeparator with example: obj = DCCRNSeparator(input_dim, num_spk, rnn_layer, rnn_units, masking_mode, use_clstm, bidirectional, use_cbn, kernel_size, kernel_num, use_builtin_complex, use_noise_mask)