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 __init__(self, cells, **kwargs):
      super().__init__(**kwargs)
      for cell in cells:
          if "call" not in dir(cell):
              raise ValueError(
                  "All cells must have a `call` method. "
                  f"Received cell without a `call` method: {cell}"
              )
          if "state_size" not in dir(cell):
              raise ValueError(
                  "All cells must have a `state_size` attribute. "
                  f"Received cell without a `state_size`: {cell}"
              )
      self.cells = cells
  
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 1 to create a new StackedRNNCells object from inherited base classes: Layer with example: obj = StackedRNNCells(cells)