docstr: Unconstrained Speech Enhancement and Separation (USES) Network.
  
  Reference:
      [1] W. Zhang, K. Saijo, Z.-Q., Wang, S. Watanabe, and Y. Qian,
      “Toward Universal Speech Enhancement for Diverse Input Conditions,”
      in Proc. ASRU, 2023.
  
  Args:
      input_dim (int): input feature dimension.
          Not used as the model is independent of the input size.
      num_spk (int): number of speakers.
      enc_channels (int): feature dimension after the Conv1D encoder.
      bottleneck_size (int): dimension of the bottleneck feature.
          Must be a multiple of `att_heads`.
      num_blocks (int): number of processing blocks.
      num_spatial_blocks (int): number of processing blocks with channel modeling.
      ref_channel (int): reference channel (used in channel modeling modules).
      segment_size (int): number of frames in each non-overlapping segment.
          This is used to segment long utterances into smaller chunks for
          efficient processing.
      memory_size (int): group size of global memory tokens.
          The basic use of memory tokens is to store the history information from
          previous segments.
          The memory tokens are updated by the output of the last block after
          processing each segment.
      memory_types (int): numbre of memory token groups.
          Each group corresponds to a different type of processing, i.e.,
              the first group is used for denoising without dereverberation,
              the second group is used for denoising with dereverberation,
      rnn_type: string, select from 'RNN', 'LSTM' and 'GRU'.
      bidirectional (bool): whether the inter-chunk RNN layers are bidirectional.
      hidden_size (int): dimension of the hidden state.
      att_heads (int): number of attention heads.
      dropout (float): dropout ratio. Default is 0.
      norm_type: type of normalization to use after each inter- or
          intra-chunk NN block.
      activation: the nonlinear activation function.
      ch_mode: str or list, mode of channel modeling. Select from "att" and "tac".
      ch_att_dim (int): dimension of the channel attention.
      ref_channel: Optional[int], index of the reference channel.
      eps (float): epsilon for layer normalization.
code: def __init__(
      self,
      input_dim: int,
      num_spk: int = 2,
      enc_channels: int = 256,
      bottleneck_size: int = 64,
      num_blocks: int = 6,
      num_spatial_blocks: int = 3,
      ref_channel: Optional[int] = None,
      segment_size: int = 64,
      memory_size: int = 20,
      memory_types: int = 1,
      # Transformer-related arguments
      rnn_type: str = "lstm",
      bidirectional: bool = True,
      hidden_size: int = 128,
      att_heads: int = 4,
      dropout: float = 0.0,
      norm_type: str = "cLN",
      activation: str = "relu",
      ch_mode: Union[str, List[str]] = "att",
      ch_att_dim: int = 256,
      eps: float = 1e-5,
      additional: dict = {},
  ):
      """Unconstrained Speech Enhancement and Separation (USES) Network.
  
      Reference:
          [1] W. Zhang, K. Saijo, Z.-Q., Wang, S. Watanabe, and Y. Qian,
          “Toward Universal Speech Enhancement for Diverse Input Conditions,”
          in Proc. ASRU, 2023.
  
      Args:
          input_dim (int): input feature dimension.
              Not used as the model is independent of the input size.
          num_spk (int): number of speakers.
          enc_channels (int): feature dimension after the Conv1D encoder.
          bottleneck_size (int): dimension of the bottleneck feature.
              Must be a multiple of `att_heads`.
          num_blocks (int): number of processing blocks.
          num_spatial_blocks (int): number of processing blocks with channel modeling.
          ref_channel (int): reference channel (used in channel modeling modules).
          segment_size (int): number of frames in each non-overlapping segment.
              This is used to segment long utterances into smaller chunks for
              efficient processing.
          memory_size (int): group size of global memory tokens.
              The basic use of memory tokens is to store the history information from
              previous segments.
              The memory tokens are updated by the output of the last block after
              processing each segment.
          memory_types (int): numbre of memory token groups.
              Each group corresponds to a different type of processing, i.e.,
                  the first group is used for denoising without dereverberation,
                  the second group is used for denoising with dereverberation,
          rnn_type: string, select from 'RNN', 'LSTM' and 'GRU'.
          bidirectional (bool): whether the inter-chunk RNN layers are bidirectional.
          hidden_size (int): dimension of the hidden state.
          att_heads (int): number of attention heads.
          dropout (float): dropout ratio. Default is 0.
          norm_type: type of normalization to use after each inter- or
              intra-chunk NN block.
          activation: the nonlinear activation function.
          ch_mode: str or list, mode of channel modeling. Select from "att" and "tac".
          ch_att_dim (int): dimension of the channel attention.
          ref_channel: Optional[int], index of the reference channel.
          eps (float): epsilon for layer normalization.
      """
      super().__init__()
  
      self._num_spk = num_spk
      self.enc_channels = enc_channels
      self.ref_channel = ref_channel
  
      # used to project each complex-valued time-frequency bin to an embedding
      self.post_encoder = torch.nn.Conv2d(
          2, enc_channels, (3, 3), padding=(1, 1)
      )
  
      assert bottleneck_size % att_heads == 0, (
          bottleneck_size,
          att_heads,
      )
      opt = {
          "memory_types": memory_types,
      }
      # arguments in `opt` can be updated at inference time to process different data
      opt.update(additional)
      self.uses = USES(
          enc_channels,
          output_size=enc_channels * num_spk,
          bottleneck_size=bottleneck_size,
          num_blocks=num_blocks,
          num_spatial_blocks=num_spatial_blocks,
          segment_size=segment_size,
          memory_size=memory_size,
          **opt,
          # Transformer-specific arguments
          rnn_type=rnn_type,
          bidirectional=bidirectional,
          hidden_size=hidden_size,
          att_heads=att_heads,
          dropout=dropout,
          norm_type=norm_type,
          activation=activation,
          ch_mode=ch_mode,
          ch_att_dim=ch_att_dim,
          eps=eps,
      )
  
      # used to project each embedding back to the complex-valued time-frequency bin
      self.pre_decoder = torch.nn.ConvTranspose2d(
          enc_channels, 2, (3, 3), padding=(1, 1)
      )
  
file_path: espnet/espnet2/enh/separator/uses_separator.py
imports: from collections import OrderedDict
  from typing import Dict, List, Optional, Tuple, Union
  import torch
  from torch_complex.tensor import ComplexTensor
  from espnet2.enh.layers.complex_utils import is_complex, new_complex_like
  from espnet2.enh.layers.uses import USES
  from espnet2.enh.separator.abs_separator import AbsSeparator
label_desc: Use image node_id 1 to create a new USESSeparator object from inherited base classes: AbsSeparator with example: obj = USESSeparator(input_dim, num_spk, enc_channels, bottleneck_size, num_blocks, num_spatial_blocks, ref_channel, segment_size, memory_size, memory_types, rnn_type, bidirectional, hidden_size, att_heads, dropout, norm_type, activation, ch_mode, ch_att_dim, eps, additional)