class_docstr: Convolutional subsampler: a stack of 1D convolution (along temporal dimension) followed by non-linear activation
  via gated linear units (https://arxiv.org/abs/1911.08460)
class_docstr_tok: ["Convolutional","subsampler",":","a","stack","of","1D","convolution","(","along","temporal","dimension",")","followed","by","non-linear","activation","via","gated","linear","units","(","https",":","\/\/arxiv.org\/abs\/1911.08460",")"]
code: def __init__(self, config):
      super(Conv1dSubsampler, self).__init__()
      self.config = config
      self.num_layers = config.num_conv_layers
      self.in_channels = (
          config.input_feat_per_channel * config.input_channels
      )
      self.mid_channels = config.conv_channels
      self.out_channels = config.d_model
      self.kernel_sizes = config.conv_kernel_sizes
  
      self.conv_layers = nn.ModuleList(
          nn.Conv1d(
              self.in_channels if i == 0 else self.mid_channels // 2,
              self.mid_channels
              if i < self.num_layers - 1
              else self.out_channels * 2,
              kernel_size=k,
              stride=2,
              padding=k // 2,
          )
          for i, k in enumerate(self.kernel_sizes)
      )
  
imports: import math
  from typing import Optional, Tuple, Union
  import torch
  from torch import nn
  from torch.nn import CrossEntropyLoss
  from ...activations import ACT2FN
  from ...modeling_attn_mask_utils import _prepare_4d_attention_mask, _prepare_4d_causal_attention_mask
  from ...modeling_outputs import BaseModelOutput, BaseModelOutputWithPastAndCrossAttentions, Seq2SeqLMOutput, Seq2SeqModelOutput
  from ...modeling_utils import PreTrainedModel
  from ...utils import add_start_docstrings, add_start_docstrings_to_model_forward, logging, replace_return_docstrings
  from .configuration_speech_to_text import Speech2TextConfig
label_desc: Use image node_id 1 to create a new Conv1dSubsampler object from inherited base classes: nn with example: obj = Conv1dSubsampler(config)