class_docstr: Residual block wrapper for black box layer.
  
  The SequenceResidualBlock class implements a generic
  (batch, length, d_input) -> (batch, length, d_input) transformation
  
  Args:
      d_input: Input feature dimension
      i_layer: Layer index, only needs to be passed into certain residuals like Decay
      dropout: Dropout for black box module
      tie_dropout: Tie dropout mask across sequence like nn.Dropout1d/nn.Dropout2d
      transposed: Transpose inputs so each layer receives (batch, dim, length)
      layer: Config for black box module
      residual: Config for residual function
      norm: Config for normalization layer
      pool: Config for pooling layer per stage
      drop_path: Drop ratio for stochastic depth
class_docstr_tok: ["Residual","block","wrapper","for","black","box","layer",".","The","SequenceResidualBlock","class","implements","a","generic","(","batch",",","length",",","d_input",")","-",">","(","batch",",","length",",","d_input",")","transformation","Args",":","d_input",":","Input","feature","dimension","i_layer",":","Layer","index",",","only","needs","to","be","passed","into","certain","residuals","like","Decay","dropout",":","Dropout","for","black","box","module","tie_dropout",":","Tie","dropout","mask","across","sequence","like","nn.Dropout1d\/nn.Dropout2d","transposed",":","Transpose","inputs","so","each","layer","receives","(","batch",",","dim",",","length",")","layer",":","Config","for","black","box","module","residual",":","Config","for","residual","function","norm",":","Config","for","normalization","layer","pool",":","Config","for","pooling","layer","per","stage","drop_path",":","Drop","ratio","for","stochastic","depth"]
code: def __init__(
      self,
      d_input,
      i_layer=None,
      prenorm=True,
      dropout=0.0,
      tie_dropout=False,
      transposed=False,
      layer=None,
      residual=None,
      norm=None,
      pool=None,
      drop_path=0.0,
  ):
      super().__init__()
  
      self.i_layer = i_layer
      self.d_input = d_input
      # self.layer = utils.instantiate(registry.layer, layer, d_input)
      if layer is None:
          layer = {}
      self.layer = utils.instantiate(registry.layer, layer, d_input)
      self.prenorm = prenorm
      self.transposed = transposed
  
      # Residual
      # d_residual is the output dimension after residual
      if residual is None:
          self.residual = None
          self.d_residual = self.layer.d_output
      else:
          self.residual = utils.instantiate(
              residual_registry,
              residual,
              i_layer,
              d_input,
              self.layer.d_output,
          )
          self.d_residual = self.residual.d_output
  
      # Normalization
      d_norm = d_input if self.prenorm else self.d_residual
      # We don't use config to directly instantiate
      # since Normalization has some special cases
      if norm is None:
          self.norm = None
      elif isinstance(norm, str):
          self.norm = Normalization(
              d_norm, transposed=self.transposed, _name_=norm
          )
      else:
          self.norm = Normalization(
              d_norm, transposed=self.transposed, **norm
          )
  
      # Pool
      self.pool = utils.instantiate(
          pool_registry,
          pool,
          self.d_residual,
          transposed=self.transposed,
      )
  
      # Dropout
      dropout_cls = (
          partial(DropoutNd, transposed=self.transposed)
          if tie_dropout
          else nn.Dropout
      )
      self.drop = (
          dropout_cls(dropout) if dropout > 0.0 else nn.Identity()
      )
  
      # Stochastic depth
      self.drop_path = (
          StochasticDepth(drop_path, mode="row")
          if drop_path > 0.0
          else nn.Identity()
      )
  
file_path: espnet/espnet2/asr/state_spaces/block.py
imports: from functools import partial
  from torch import nn
  import espnet2.asr.state_spaces.utils
  from espnet2.asr.state_spaces import registry
  from espnet2.asr.state_spaces.base import SequenceModule
  from espnet2.asr.state_spaces.components import DropoutNd, Normalization, StochasticDepth
  from espnet2.asr.state_spaces.pool import registry
  from espnet2.asr.state_spaces.residual import registry
label_desc: Use image node_id 1 to create a new SequenceResidualBlock object from inherited base classes: SequenceModule with example: obj = SequenceResidualBlock(d_input, i_layer, prenorm, dropout, tie_dropout, transposed, layer, residual, norm, pool, drop_path)