code: def test_dynamic_shapes(self):
      sequence_shape = (None, None, 3)
      layer = layers.RNN(OneStateRNNCell(8), return_sequences=False)
      output_shape = layer.compute_output_shape(sequence_shape)
      self.assertEqual(output_shape, (None, 8))
  
      layer = layers.RNN(OneStateRNNCell(8), return_sequences=True)
      output_shape = layer.compute_output_shape(sequence_shape)
      self.assertEqual(output_shape, (None, None, 8))
  
      layer = layers.RNN(
          OneStateRNNCell(8), return_sequences=False, return_state=True
      )
      output_shape = layer.compute_output_shape(sequence_shape)
      self.assertEqual(output_shape[0], (None, 8))
      self.assertEqual(output_shape[1], (None, 8))
  
      layer = layers.RNN(
          OneStateRNNCell(8), return_sequences=True, return_state=True
      )
      output_shape = layer.compute_output_shape(sequence_shape)
      self.assertEqual(output_shape[0], (None, None, 8))
      self.assertEqual(output_shape[1], (None, 8))
  
      layer = layers.RNN(TwoStatesRNNCell(8), return_sequences=False)
      output_shape = layer.compute_output_shape(sequence_shape)
      self.assertEqual(output_shape, (None, 8))
  
      layer = layers.RNN(TwoStatesRNNCell(8), return_sequences=True)
      output_shape = layer.compute_output_shape(sequence_shape)
      self.assertEqual(output_shape, (None, None, 8))
  
      layer = layers.RNN(
          TwoStatesRNNCell(8), return_sequences=False, return_state=True
      )
      output_shape = layer.compute_output_shape(sequence_shape)
      self.assertEqual(output_shape[0], (None, 8))
      self.assertEqual(output_shape[1], (None, 8))
      self.assertEqual(output_shape[2], (None, 8))
  
      layer = layers.RNN(
          TwoStatesRNNCell(8), return_sequences=True, return_state=True
      )
      output_shape = layer.compute_output_shape(sequence_shape)
      self.assertEqual(output_shape[0], (None, None, 8))
      self.assertEqual(output_shape[1], (None, 8))
      self.assertEqual(output_shape[2], (None, 8))
  
imports: import numpy
  import pytest
  from keras import layers
  from keras import ops
  from keras import testing
label_desc: Use image node_id 4 for calling the RNNTest obj's underlying member method code with example usage: obj.test_dynamic_shapes() without return types