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
docstr: Apply processing sequence to data with optional previous input.
  
  :param data: Input data. Shape: (batch, length, num_hidden).
  :param prev: Previous data. Shape: (batch, length, num_hidden).
  :return: Processed data. Shape: (batch, length, num_hidden).
docstr_tok: ["Apply","processing","sequence","to","data","with","optional","previous","input",".",":","param","data",":","Input","data",".","Shape",":","(","batch",",","length",",","num_hidden",")",".",":","param","prev",":","Previous","data",".","Shape",":","(","batch",",","length",",","num_hidden",")",".",":","return",":","Processed","data",".","Shape",":","(","batch",",","length",",","num_hidden",")","."]
code: def forward(
      self, data: pt.Tensor, prev: Optional[pt.Tensor] = None
  ) -> pt.Tensor:
      """
      Apply processing sequence to data with optional previous input.
  
      :param data: Input data. Shape: (batch, length, num_hidden).
      :param prev: Previous data. Shape: (batch, length, num_hidden).
      :return: Processed data. Shape: (batch, 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 = data + prev
  
          elif step == "n":
              data = self.layer_norm(data)
  
          elif step == "d":
              data = self.drop(data)
          else:
              raise ValueError("Unknown step in sequence: %s" % step)
  
      if self.clamp_to_dtype:
          data = sockeye.layers.clamp_to_dtype_min_max(data)
  
      return data
  
imports: from dataclasses import dataclass
  from typing import Optional, Tuple
  import torch
  import sockeye.layers
  from sockeye import constants
  from .None import config
label_desc: Use image node_id 2 for calling the TransformerProcessBlock obj's underlying member method code with example usage: obj.forward(data, prev) and returns: data, data