code: def forward(
      self,
      embedded_tokens: torch.Tensor,
      states: Tuple[torch.Tensor, torch.Tensor],
      seq_lengths: List[int],
  ) -> Tuple[torch.Tensor, Tuple[torch.Tensor, torch.Tensor]]:
      hidden, context = states
      batch_size = hidden.size(0)
      all_context = []
      all_hidden = []
  
      if self.dropout.p > 0.0:
          embedded_tokens = self.dropout(embedded_tokens)
  
      for batch in embedded_tokens:
          # Compute the normal LSTM gates
          combined = torch.cat((batch, hidden), 1)
          ft = self.f_gate(combined).sigmoid()
          it = self.i_gate(combined).sigmoid()
          ot = self.o_gate(combined).sigmoid()
          c_hat = self.c_hat_gate(combined).tanh()
  
          # Compute the master gates
          master_forget_no_cumax = self.master_forget_no_cumax_gate(
              combined
          )
          master_forget = torch.cumsum(
              F.softmax(master_forget_no_cumax, dim=1), dim=1
          )
          master_input_no_cumax = self.master_input_no_cumax_gate(
              combined
          )
          master_input = torch.cumsum(
              F.softmax(master_input_no_cumax, dim=1), dim=1
          )
  
          # Combine master gates with normal LSTM gates
          wt = master_forget * master_input
          f_hat_t = ft * wt + (master_forget - wt)
          i_hat_t = it * wt + (master_input - wt)
  
          # Compute new context and hidden using final combined gates
          context = f_hat_t * context + i_hat_t * c_hat
          hidden = ot * context
          all_context.append(context)
          all_hidden.append(hidden)
  
      # Compute what the final state (hidden and context for each element
      # in the batch) should be based on seq_lengths
      state_hidden = []
      state_context = []
  
      for i in range(batch_size):
          seq_length = seq_lengths[i]
          state_hidden.append(all_hidden[seq_length - 1][i])
          state_context.append(all_context[seq_length - 1][i])
  
      # Return hidden states across all time steps, and return a tuple
      # containing the hidden and context for the last time step (might
      # be different based on seq_lengths)
      return (
          torch.stack(all_hidden),
          (torch.stack(state_hidden), torch.stack(state_context)),
      )
  
file_path: pytext/pytext/models/representations/ordered_neuron_lstm.py
imports: from typing import List, Optional, Tuple
  import torch
  import torch.nn
  import torch.nn.functional
  from pytext.config import ConfigBase
  from pytext.models.module import Module
  from pytext.utils import cuda
  from pytext.utils.usage import log_class_usage
  from .representation_base import RepresentationBase
label_desc: Use image node_id 2 for calling the OrderedNeuronLSTMLayer obj's underlying member method code with example usage: obj.forward(embedded_tokens, states, seq_lengths) and returns: torch,  torch,  torch