class_docstr: Wrapper allowing a stack of RNN cells to behave as a single cell.
  
  Used to implement efficient stacked RNNs.
  
  Args:
    cells: List of RNN cell instances.
  
  Examples:
  
  ```python
  batch_size = 3
  sentence_length = 5
  num_features = 2
  new_shape = (batch_size, sentence_length, num_features)
  x = np.reshape(np.arange(30), new_shape)
  
  rnn_cells = [keras.layers.LSTMCell(128) for _ in range(2)]
  stacked_lstm = keras.layers.StackedRNNCells(rnn_cells)
  lstm_layer = keras.layers.RNN(stacked_lstm)
  
  result = lstm_layer(x)
  ```
class_docstr_tok: ["Wrapper","allowing","a","stack","of","RNN","cells","to","behave","as","a","single","cell",".","Used","to","implement","efficient","stacked","RNNs",".","Args",":","cells",":","List","of","RNN","cell","instances",".","Examples",":","``","`","python","batch_size","=","3","sentence_length","=","5","num_features","=","2","new_shape","=","(","batch_size",",","sentence_length",",","num_features",")","x","=","np.reshape","(","np.arange","(","30",")",",","new_shape",")","rnn_cells","=","[","keras.layers.LSTMCell","(","128",")","for","_","in","range","(","2",")","]","stacked_lstm","=","keras.layers.StackedRNNCells","(","rnn_cells",")","lstm_layer","=","keras.layers.RNN","(","stacked_lstm",")","result","=","lstm_layer","(","x",")","``","`"]
code: def get_initial_state(self, batch_size=None):
      initial_states = []
      for cell in self.cells:
          get_initial_state_fn = getattr(
              cell, "get_initial_state", None
          )
          if get_initial_state_fn:
              initial_states.append(
                  get_initial_state_fn(batch_size=batch_size)
              )
          else:
              if isinstance(cell.state_size, int):
                  initial_states.append(
                      ops.zeros(
                          (batch_size, cell.state_size),
                          dtype=self.compute_dtype,
                      )
                  )
              else:
                  initial_states.append(
                      [
                          ops.zeros(
                              (batch_size, d), dtype=self.compute_dtype
                          )
                          for d in cell.state_size
                      ]
                  )
      return initial_states
  
file_path: keras/keras/layers/rnn/stacked_rnn_cells.py
imports: import tree
  from keras import ops
  from keras.api_export import keras_export
  from keras.layers.layer import Layer
  from keras.saving import serialization_lib
label_desc: Use image node_id 4 for calling the StackedRNNCells obj's underlying member method code with example usage: obj.get_initial_state(batch_size) and returns: initial_states