code: def testChangingStateShape(self):
      # Test the fixed-point shape invariant calculations: start with
      # initial values with known shapes, and use a scan function that
      # changes the size of the state on each element.
      def _scan_fn(state, input_value):
          # Statically known rank, but dynamic length.
          ret_longer_vector = array_ops.concat([state[0], state[0]], 0)
          # Statically unknown rank.
          ret_larger_rank = array_ops.expand_dims(state[1], 0)
          return (ret_longer_vector, ret_larger_rank), (
              state,
              input_value,
          )
  
      dataset = (
          dataset_ops.Dataset.from_tensors(0)
          .repeat(5)
          .scan(initial_state=([0], 1), scan_func=_scan_fn)
      )
      self.assertEqual(
          [None],
          dataset_ops.get_legacy_output_shapes(dataset)[0][0].as_list(),
      )
      self.assertIs(
          None,
          dataset_ops.get_legacy_output_shapes(dataset)[0][1].ndims,
      )
      self.assertEqual(
          [], dataset_ops.get_legacy_output_shapes(dataset)[1].as_list()
      )
  
      next_element = self.getNext(dataset)
  
      for i in range(5):
          (longer_vector_val, larger_rank_val), _ = self.evaluate(
              next_element()
          )
          self.assertAllEqual([0] * (2**i), longer_vector_val)
          self.assertAllEqual(np.array(1, ndmin=i), larger_rank_val)
      with self.assertRaises(errors.OutOfRangeError):
          self.evaluate(next_element())
  
imports: import itertools
  from absl.testing import parameterized
  import numpy
  from tensorflow.python.data.kernel_tests import checkpoint_test_base
  from tensorflow.python.data.kernel_tests import test_base
  from tensorflow.python.data.ops import dataset_ops
  from tensorflow.python.data.ops import options
  from tensorflow.python.data.ops import scan_op
  from tensorflow.python.framework import combinations
  from tensorflow.python.framework import constant_op
  from tensorflow.python.framework import dtypes
  from tensorflow.python.framework import errors
  from tensorflow.python.framework import ops
  from tensorflow.python.framework import sparse_tensor
  from tensorflow.python.framework import test_ops
  from tensorflow.python.framework import test_util
  from tensorflow.python.ops import array_ops
  from tensorflow.python.ops import cond
  from tensorflow.python.ops import control_flow_v2_toggles
  from tensorflow.python.ops import math_ops
  from tensorflow.python.ops import script_ops
  from tensorflow.python.ops import tensor_array_ops
  from tensorflow.python.ops import variables
  from tensorflow.python.platform import test
label_desc: Use image node_id 8 for calling the ScanTest obj's underlying member method code with example usage: obj.testChangingStateShape() and returns: ret_longer_vector,  ret_larger_rank,  state,  input_value