code: def forward(self, inputs: torch.Tensor, mask=None):
      hidden, final_state = self.layers(inputs)
  
      if isinstance(final_state, tuple):
          # lstm cell type
          final_state = final_state[0][-1], final_state[1][-1]
      else:
          # rnn or gru cell type
          final_state = final_state[-1]
  
      return hidden, final_state
  
file_path: ludwig/ludwig/modules/recurrent_modules.py
imports: import logging
  from typing import Optional
  import torch
  from torch.nn import GRU, LSTM, RNN
  from ludwig.utils.misc_utils import get_from_registry
  from ludwig.utils.torch_utils import LudwigModule
label_desc: Use image node_id 4 for calling the RecurrentStack obj's underlying member method code with example usage: obj.forward(inputs, mask) and returns: hidden,  final_state