class_docstr: Length Adaptor PostEncoder.
docstr: Initialize the module.
docstr_tok: ["Initialize","the","module","."]
code: def __init__(
      self,
      input_size: int,
      length_adaptor_n_layers: int = 0,
      input_layer: Optional[str] = None,
      output_size: Optional[int] = None,
      dropout_rate: float = 0.1,
      return_int_enc: bool = False,
  ):
      """Initialize the module."""
      assert check_argument_types()
      super().__init__()
  
      if input_layer == "linear":
          self.embed = torch.nn.Sequential(
              torch.nn.Linear(input_size, output_size),
              torch.nn.LayerNorm(output_size),
              torch.nn.Dropout(dropout_rate),
          )
          self.out_sz = output_size
      else:
          self.embed = None
          self.out_sz = input_size
  
      # Length Adaptor as in https://aclanthology.org/2021.acl-long.68.pdf
  
      if length_adaptor_n_layers > 0:
          length_adaptor_layers = []
          for _ in range(length_adaptor_n_layers):
              length_adaptor_layers.append(
                  torch.nn.Conv1d(self.out_sz, self.out_sz, 2, 2)
              )
              length_adaptor_layers.append(torch.nn.ReLU())
      else:
          length_adaptor_layers = [torch.nn.Identity()]
  
      self.length_adaptor = torch.nn.Sequential(*length_adaptor_layers)
      self.length_adaptor_ratio = 2**length_adaptor_n_layers
      self.return_int_enc = return_int_enc
  
file_path: espnet/espnet2/asr/postencoder/length_adaptor_postencoder.py
imports: from typing import Optional, Tuple
  import torch
  from typeguard import check_argument_types
  from espnet2.asr.postencoder.abs_postencoder import AbsPostEncoder
  from espnet.nets.pytorch_backend.transformer.subsampling import TooShortUttError
label_desc: Use image node_id 1 to create a new LengthAdaptorPostEncoder object from inherited base classes: AbsPostEncoder with example: obj = LengthAdaptorPostEncoder(input_size, length_adaptor_n_layers, input_layer, output_size, dropout_rate, return_int_enc)