class_docstr: Transformer encoder module.
  
  :param int idim: input dim
  :param int attention_dim: dimension of attention
  :param int attention_heads: the number of heads of multi head attention
  :param int linear_units: the number of units of position-wise feed forward
  :param int num_blocks: the number of decoder blocks
  :param float dropout_rate: dropout rate
  :param float attention_dropout_rate: dropout rate in attention
  :param float positional_dropout_rate: dropout rate after adding positional encoding
  :param str or torch.nn.Module input_layer: input layer type
  :param class pos_enc_class: PositionalEncoding or ScaledPositionalEncoding
  :param bool normalize_before: whether to use layer_norm before the first block
  :param bool concat_after: whether to concat attention layer's input and output
      if True, additional linear will be applied.
      i.e. x -> x + linear(concat(x, att(x)))
      if False, no additional linear will be applied. i.e. x -> x + att(x)
  :param str positionwise_layer_type: linear of conv1d
  :param int positionwise_conv_kernel_size: kernel size of positionwise conv1d layer
  :param int padding_idx: padding_idx for input_layer=embed
class_docstr_tok: ["Transformer","encoder","module",".",":","param","int","idim",":","input","dim",":","param","int","attention_dim",":","dimension","of","attention",":","param","int","attention_heads",":","the","number","of","heads","of","multi","head","attention",":","param","int","linear_units",":","the","number","of","units","of","position-wise","feed","forward",":","param","int","num_blocks",":","the","number","of","decoder","blocks",":","param","float","dropout_rate",":","dropout","rate",":","param","float","attention_dropout_rate",":","dropout","rate","in","attention",":","param","float","positional_dropout_rate",":","dropout","rate","after","adding","positional","encoding",":","param","str","or","torch.nn.Module","input_layer",":","input","layer","type",":","param","class","pos_enc_class",":","PositionalEncoding","or","ScaledPositionalEncoding",":","param","bool","normalize_before",":","whether","to","use","layer_norm","before","the","first","block",":","param","bool","concat_after",":","whether","to","concat","attention","layer","'s","input","and","output","if","True",",","additional","linear","will","be","applied",".","i.e",".","x","-",">","x","+","linear","(","concat","(","x",",","att","(","x",")",")",")","if","False",",","no","additional","linear","will","be","applied",".","i.e",".","x","-",">","x","+","att","(","x",")",":","param","str","positionwise_layer_type",":","linear","of","conv1d",":","param","int","positionwise_conv_kernel_size",":","kernel","size","of","positionwise","conv1d","layer",":","param","int","padding_idx",":","padding_idx","for","input_layer=embed"]
docstr: Construct an Encoder object.
docstr_tok: ["Construct","an","Encoder","object","."]
code: def __init__(
      self,
      idim,
      attention_dim=256,
      attention_heads=4,
      linear_units=2048,
      num_blocks_sd=4,
      num_blocks_rec=8,
      dropout_rate=0.1,
      positional_dropout_rate=0.1,
      attention_dropout_rate=0.0,
      input_layer="conv2d",
      pos_enc_class=PositionalEncoding,
      normalize_before=True,
      concat_after=False,
      positionwise_layer_type="linear",
      positionwise_conv_kernel_size=1,
      padding_idx=-1,
      num_spkrs=2,
  ):
      """Construct an Encoder object."""
      super(EncoderMix, self).__init__(
          idim=idim,
          selfattention_layer_type="selfattn",
          attention_dim=attention_dim,
          attention_heads=attention_heads,
          linear_units=linear_units,
          num_blocks=num_blocks_rec,
          dropout_rate=dropout_rate,
          positional_dropout_rate=positional_dropout_rate,
          attention_dropout_rate=attention_dropout_rate,
          input_layer=input_layer,
          pos_enc_class=pos_enc_class,
          normalize_before=normalize_before,
          concat_after=concat_after,
          positionwise_layer_type=positionwise_layer_type,
          positionwise_conv_kernel_size=positionwise_conv_kernel_size,
          padding_idx=padding_idx,
      )
      (
          positionwise_layer,
          positionwise_layer_args,
      ) = self.get_positionwise_layer(
          positionwise_layer_type,
          attention_dim,
          linear_units,
          dropout_rate,
          positionwise_conv_kernel_size,
      )
      self.num_spkrs = num_spkrs
      self.encoders_sd = torch.nn.ModuleList(
          [
              repeat(
                  num_blocks_sd,
                  lambda lnum: EncoderLayer(
                      attention_dim,
                      MultiHeadedAttention(
                          attention_heads,
                          attention_dim,
                          attention_dropout_rate,
                      ),
                      positionwise_layer(*positionwise_layer_args),
                      dropout_rate,
                      normalize_before,
                      concat_after,
                  ),
              )
              for i in range(num_spkrs)
          ]
      )
  
file_path: espnet/espnet/nets/pytorch_backend/transformer/encoder_mix.py
imports: import torch
  from espnet.nets.pytorch_backend.transducer.vgg2l import VGG2L
  from espnet.nets.pytorch_backend.transformer.attention import MultiHeadedAttention
  from espnet.nets.pytorch_backend.transformer.embedding import PositionalEncoding
  from espnet.nets.pytorch_backend.transformer.encoder import Encoder
  from espnet.nets.pytorch_backend.transformer.encoder_layer import EncoderLayer
  from espnet.nets.pytorch_backend.transformer.repeat import repeat
  from espnet.nets.pytorch_backend.transformer.subsampling import Conv2dSubsampling
label_desc: Use image node_id 1 to create a new EncoderMix object from inherited base classes: Encoder, torch.nn with example: obj = EncoderMix(idim, attention_dim, attention_heads, linear_units, num_blocks_sd, num_blocks_rec, dropout_rate, positional_dropout_rate, attention_dropout_rate, input_layer, pos_enc_class, normalize_before, concat_after, positionwise_layer_type, positionwise_conv_kernel_size, padding_idx, num_spkrs)