docstr: Args:
      input_layers: list of linear layer dimensions. These layers are
          applied to the input features and are followed by tanh and
          possibly dropout.
      conv_layers: list of conv2d layer configurations. A configuration is
          a tuple (out_channels, conv_kernel_size, stride).
      in_channels: number of input channels.
      input_feat_per_channel: number of input features per channel. These
          are speech features, typically 40 or 80.
      num_blstm_layers: number of bidirectional LSTM layers.
      lstm_size: size of the LSTM hidden (and cell) size.
      dropout: dropout probability. Dropout can be applied after the
          linear layers and LSTM layers but not to the convolutional
          layers.
docstr_tok: ["Args",":","input_layers",":","list","of","linear","layer","dimensions",".","These","layers","are","applied","to","the","input","features","and","are","followed","by","tanh","and","possibly","dropout",".","conv_layers",":","list","of","conv2d","layer","configurations",".","A","configuration","is","a","tuple","(","out_channels",",","conv_kernel_size",",","stride",")",".","in_channels",":","number","of","input","channels",".","input_feat_per_channel",":","number","of","input","features","per","channel",".","These","are","speech","features",",","typically","40","or","80.","num_blstm_layers",":","number","of","bidirectional","LSTM","layers",".","lstm_size",":","size","of","the","LSTM","hidden","(","and","cell",")","size",".","dropout",":","dropout","probability",".","Dropout","can","be","applied","after","the","linear","layers","and","LSTM","layers","but","not","to","the","convolutional","layers","."]
code: def __init__(
      self,
      input_layers: List[int],
      conv_layers: List[Tuple[int]],
      in_channels: int,
      input_feat_per_channel: int,
      num_blstm_layers: int,
      lstm_size: int,
      dropout: float,
  ):
      """
      Args:
          input_layers: list of linear layer dimensions. These layers are
              applied to the input features and are followed by tanh and
              possibly dropout.
          conv_layers: list of conv2d layer configurations. A configuration is
              a tuple (out_channels, conv_kernel_size, stride).
          in_channels: number of input channels.
          input_feat_per_channel: number of input features per channel. These
              are speech features, typically 40 or 80.
          num_blstm_layers: number of bidirectional LSTM layers.
          lstm_size: size of the LSTM hidden (and cell) size.
          dropout: dropout probability. Dropout can be applied after the
              linear layers and LSTM layers but not to the convolutional
              layers.
      """
      super().__init__(None)
  
      self.input_layers = nn.ModuleList()
      in_features = input_feat_per_channel
      for out_features in input_layers:
          if dropout > 0:
              self.input_layers.append(
                  nn.Sequential(
                      nn.Linear(in_features, out_features),
                      nn.Dropout(p=dropout),
                  )
              )
          else:
              self.input_layers.append(
                  nn.Linear(in_features, out_features)
              )
          in_features = out_features
  
      self.in_channels = in_channels
      self.input_dim = input_feat_per_channel
      self.conv_kernel_sizes_and_strides = []
      self.conv_layers = nn.ModuleList()
      lstm_input_dim = input_layers[-1]
      for conv_layer in conv_layers:
          out_channels, conv_kernel_size, conv_stride = conv_layer
          self.conv_layers.append(
              nn.Conv2d(
                  in_channels,
                  out_channels,
                  conv_kernel_size,
                  stride=conv_stride,
                  padding=conv_kernel_size // 2,
              )
          )
          self.conv_kernel_sizes_and_strides.append(
              (conv_kernel_size, conv_stride)
          )
          in_channels = out_channels
          lstm_input_dim //= conv_stride
  
      lstm_input_dim *= conv_layers[-1][0]
      self.lstm_size = lstm_size
      self.num_blstm_layers = num_blstm_layers
      self.lstm = nn.LSTM(
          input_size=lstm_input_dim,
          hidden_size=lstm_size,
          num_layers=num_blstm_layers,
          dropout=dropout,
          bidirectional=True,
      )
      self.output_dim = 2 * lstm_size  # bidirectional
      if dropout > 0:
          self.dropout = nn.Dropout(p=dropout)
      else:
          self.dropout = None
  
imports: from ast import literal_eval
  from typing import List, Tuple
  import torch
  import torch.nn
  import torch.nn.functional
  from fairseq import checkpoint_utils, utils
  from fairseq.data.data_utils import lengths_to_padding_mask
  from fairseq.models import FairseqEncoder, FairseqEncoderDecoderModel, FairseqIncrementalDecoder, register_model, register_model_architecture
label_desc: Use image node_id 1 to create a new BerardEncoder object from inherited base classes: FairseqEncoder with example: obj = BerardEncoder(input_layers, conv_layers, in_channels, input_feat_per_channel, num_blstm_layers, lstm_size, dropout)