class_docstr: Block to perform pre/post processing on layer inputs.
  The processing steps are determined by the sequence argument, which can
  contain one of the three operations:
  n: layer normalization
  r: residual connection
  d: dropout
class_docstr_tok: ["Block","to","perform","pre\/post","processing","on","layer","inputs",".","The","processing","steps","are","determined","by","the","sequence","argument",",","which","can","contain","one","of","the","three","operations",":","n",":","layer","normalization","r",":","residual","connection","d",":","dropout"]
docstr: Apply processing sequence to data with optional previous input.
  
  Parameters
  ----------
  data
      Input data of shape: (batch_size, length, num_hidden)
  prev
      Previous data of shape (batch_size, length, num_hidden)
  
  Returns
  -------
  Processed data of shape (batch_size, length, num_hidden).
docstr_tok: ["Apply","processing","sequence","to","data","with","optional","previous","input",".","Parameters","--","--","--","--","--","data","Input","data","of","shape",":","(","batch_size",",","length",",","num_hidden",")","prev","Previous","data","of","shape","(","batch_size",",","length",",","num_hidden",")","Returns","--","--","--","-","Processed","data","of","shape","(","batch_size",",","length",",","num_hidden",")","."]
code: def hybrid_forward(
      self, F, data: Tensor, prev: Optional[Tensor] = None
  ) -> Tensor:
      r"""
      Apply processing sequence to data with optional previous input.
  
      Parameters
      ----------
      data
          Input data of shape: (batch_size, length, num_hidden)
      prev
          Previous data of shape (batch_size, length, num_hidden)
  
      Returns
      -------
      Processed data of shape (batch_size, length, num_hidden).
      """
      if not self.sequence:
          return data
  
      if prev is None:
          assert (
              "r" not in self.sequence
          ), "Residual connection not allowed if no previous value given."
  
      for step in self.sequence:
          if step == "r":
              data = F.broadcast_add(data, prev)
  
          elif step == "n":
              assert self.layer_norm is not None
              data = self.layer_norm(data)
  
          elif step == "d":
              if self.dropout > 0.0:
                  data = F.Dropout(data, p=self.dropout)
          else:
              raise ValueError("Unknown step in sequence: %s" % step)
  
      return data
  
imports: from typing import Dict, Optional, Tuple
  import mxnet
  from mxnet.gluon import HybridBlock
  from gluonts.mx import Tensor
label_desc: Use image node_id 2 for calling the TransformerProcessBlock obj's underlying member method code with example usage: obj.hybrid_forward(F, data, prev) and returns: data, data