code: def test_reshape(self, sparse):
      if sparse and not backend.SUPPORTS_SPARSE_TENSORS:
          pytest.skip("Backend does not support sparse tensors.")
  
      self.run_layer_test(
          layers.Reshape,
          init_kwargs={"target_shape": (8, 1)},
          input_shape=(3, 2, 4),
          input_sparse=sparse,
          expected_output_shape=(3, 8, 1),
          expected_output_sparse=sparse,
          run_training_check=not sparse,
      )
  
      self.run_layer_test(
          layers.Reshape,
          init_kwargs={"target_shape": (8,)},
          input_shape=(3, 2, 4),
          input_sparse=sparse,
          expected_output_shape=(3, 8),
          expected_output_sparse=sparse,
          run_training_check=not sparse,
      )
  
      self.run_layer_test(
          layers.Reshape,
          init_kwargs={"target_shape": (2, 4)},
          input_shape=(3, 8),
          input_sparse=sparse,
          expected_output_shape=(3, 2, 4),
          expected_output_sparse=sparse,
          run_training_check=not sparse,
      )
      self.run_layer_test(
          layers.Reshape,
          init_kwargs={"target_shape": (-1, 1)},
          input_shape=(3, 2, 4),
          input_sparse=sparse,
          expected_output_shape=(3, 8, 1),
          expected_output_sparse=sparse,
          run_training_check=not sparse,
      )
  
      self.run_layer_test(
          layers.Reshape,
          init_kwargs={"target_shape": (1, -1)},
          input_shape=(3, 2, 4),
          input_sparse=sparse,
          expected_output_shape=(3, 1, 8),
          expected_output_sparse=sparse,
          run_training_check=not sparse,
      )
  
      self.run_layer_test(
          layers.Reshape,
          init_kwargs={"target_shape": (-1,)},
          input_shape=(3, 2, 4),
          input_sparse=sparse,
          expected_output_shape=(3, 8),
          expected_output_sparse=sparse,
          run_training_check=not sparse,
      )
  
      self.run_layer_test(
          layers.Reshape,
          init_kwargs={"target_shape": (2, -1)},
          input_shape=(3, 2, 4),
          input_sparse=sparse,
          expected_output_shape=(3, 2, 4),
          expected_output_sparse=sparse,
          run_training_check=not sparse,
      )
  
file_path: keras/keras/layers/reshaping/reshape_test.py
imports: import pytest
  from absl.testing import parameterized
  from keras import backend
  from keras import layers
  from keras import testing
  from keras.backend.common.keras_tensor import KerasTensor
label_desc: Use image node_id 1 for calling the ReshapeTest obj's underlying member method code with example usage: obj.test_reshape(sparse) without return types