code: def __init__(self, onnx_node, run_params):  # type: ignore
      OpRun.__init__(self, onnx_node, run_params)
  
      if self.direction in ("forward", "reverse"):  # type: ignore
          self.num_directions = 1  # type: ignore
      elif self.direction == "bidirectional":  # type: ignore
          self.num_directions = 2  # type: ignore
      else:
          raise RuntimeError(f"Unknown direction {self.direction!r}.")  # type: ignore
  
      if (
          self.activation_alpha is not None  # type: ignore
          and len(self.activation_alpha) != self.num_directions  # type: ignore
      ):
          raise RuntimeError(
              f"activation_alpha must have the same size as num_directions={self.num_directions}."  # type: ignore
          )
      if (
          self.activation_beta is not None  # type: ignore
          and len(self.activation_beta) != self.num_directions  # type: ignore
      ):
          raise RuntimeError(
              f"activation_beta must have the same size as num_directions={self.num_directions}."  # type: ignore
          )
  
      self.f1 = self.choose_act(
          self.activations[0],  # type: ignore
          self.activation_alpha[0]  # type: ignore
          if self.activation_alpha is not None and len(self.activation_alpha) > 0  # type: ignore
          else None,
          self.activation_beta[0]  # type: ignore
          if self.activation_beta is not None and len(self.activation_beta) > 0  # type: ignore
          else None,
      )
      if len(self.activations) > 1:  # type: ignore
          self.f2 = self.choose_act(
              self.activations[1],  # type: ignore
              self.activation_alpha[1]  # type: ignore
              if self.activation_alpha is not None and len(self.activation_alpha) > 1  # type: ignore
              else None,
              self.activation_beta[1]  # type: ignore
              if self.activation_beta is not None and len(self.activation_beta) > 1  # type: ignore
              else None,
          )
      self.n_outputs = len(onnx_node.output)
  
file_path: onnx/onnx/reference/ops/op_rnn.py
imports: import numpy
  from onnx.reference.op_run import OpRun
label_desc: Use image node_id 1 to create a new CommonRNN object from inherited base classes: OpRun with example: obj = CommonRNN(onnx_node, run_params)