class_docstr: Isotropic deep sequence model backbone, in the style of ResNets / Transformers.
  
  The SequenceModel class implements a generic
  (batch, length, d_input) -> (batch, length, d_output) transformation
  
  Args:
      d_model: Resize input (useful for deep models with residuals)
      n_layers: Number of layers
      transposed: Transpose inputs so each layer receives (batch, dim, length)
      dropout: Dropout parameter applied on every residual and every layer
      tie_dropout: Tie dropout mask across sequence like nn.Dropout1d/nn.Dropout2d
      prenorm: Pre-norm vs. post-norm
      n_repeat: Each layer is repeated n times per stage before applying pooling
      layer: Layer config, must be specified
      residual: Residual config
      norm: Normalization config (e.g. layer vs batch)
      pool: Config for pooling layer per stage
      track_norms: Log norms of each layer output
      dropinp: Input dropout
      drop_path: Stochastic depth for each residual path
code: def __init__(
      self,
      d_model,
      n_layers=1,
      transposed=False,
      dropout=0.0,
      tie_dropout=False,
      prenorm=True,
      n_repeat=1,
      layer=None,
      residual=None,
      norm=None,
      pool=None,
      track_norms=True,
      dropinp=0.0,
      drop_path=0.0,
  ):
      super().__init__()
      # Save arguments needed for forward pass
      self.d_model = d_model
      self.transposed = transposed
      self.track_norms = track_norms
  
      # Input dropout (not really used)
      dropout_fn = (
          partial(DropoutNd, transposed=self.transposed)
          if tie_dropout
          else nn.Dropout
      )
      self.drop = (
          dropout_fn(dropinp) if dropinp > 0.0 else nn.Identity()
      )
      layer = to_list(layer, recursive=False)
  
      # Some special arguments are passed into each layer
      for _layer in layer:
          # If layers don't specify dropout, add it
          if _layer.get("dropout", None) is None:
              _layer["dropout"] = dropout
          # Ensure all layers are shaped the same way
          _layer["transposed"] = transposed
  
      # Duplicate layers
      layers = layer * n_layers * n_repeat
  
      # Instantiate layers
      _layers = []
      d = d_model
      for i, layer in enumerate(layers):
          # Pool at the end of every n_repeat blocks
          pool_cfg = pool if (i + 1) % n_repeat == 0 else None
          block = SequenceResidualBlock(
              d,
              i + 1,
              prenorm=prenorm,
              dropout=dropout,
              tie_dropout=tie_dropout,
              transposed=transposed,
              layer=layer,
              residual=residual,
              norm=norm,
              pool=pool_cfg,
              drop_path=drop_path,
          )
          _layers.append(block)
          d = block.d_output
  
      self.d_output = d
      self.layers = nn.ModuleList(_layers)
      if prenorm:
          if norm is None:
              self.norm = None
          elif isinstance(norm, str):
              self.norm = Normalization(
                  self.d_output, transposed=self.transposed, _name_=norm
              )
          else:
              self.norm = Normalization(
                  self.d_output, transposed=self.transposed, **norm
              )
      else:
          self.norm = nn.Identity()
  
file_path: espnet/espnet2/asr/state_spaces/model.py
imports: from functools import partial
  import torch
  import torch.nn
  from einops import rearrange
  from espnet2.asr.state_spaces.base import SequenceModule
  from espnet2.asr.state_spaces.block import SequenceResidualBlock
  from espnet2.asr.state_spaces.components import DropoutNd, Normalization
  from espnet2.asr.state_spaces.utils import to_dict, to_list
label_desc: Use image node_id 1 to create a new SequenceModel object from inherited base classes: SequenceModule with example: obj = SequenceModel(d_model, n_layers, transposed, dropout, tie_dropout, prenorm, n_repeat, layer, residual, norm, pool, track_norms, dropinp, drop_path)