code: def testStatefulExternalPolicy(self):
      checkpoint_directory = self.get_temp_dir()
      checkpoint_prefix = os.path.join(checkpoint_directory, "ckpt")
      dataset = dataset_ops.Dataset.range(4)
  
      def fn(x):
          return x * x
  
      dataset = dataset.map(
          lambda x: script_ops.eager_py_func(fn, [x], dtypes.int64)
      )
  
      options = options_lib.Options()
      options.experimental_external_state_policy = (
          options_lib.ExternalStatePolicy.WARN
      )
      dataset = dataset.with_options(options)
  
      iterator = iter(dataset)
      get_next = iterator.get_next
      checkpoint = trackable_utils.Checkpoint(iterator=iterator)
      self.assertEqual(0, get_next().numpy())
      self.assertEqual(1, get_next().numpy())
      save_path = checkpoint.save(checkpoint_prefix)
      self.assertEqual(4, get_next().numpy())
      self.assertEqual(9, get_next().numpy())
      checkpoint.restore(save_path).run_restore_ops()
      self.assertEqual(4, get_next().numpy())
      self.assertEqual(9, get_next().numpy())
      with self.assertRaises(errors.OutOfRangeError):
          get_next()
  
imports: import os
  from absl.testing import parameterized
  from tensorflow.python.checkpoint import checkpoint
  from tensorflow.python.checkpoint import checkpoint_management
  from tensorflow.python.checkpoint import checkpoint_options
  from tensorflow.python.data.experimental.ops import grouping
  from tensorflow.python.data.experimental.ops import interleave_ops
  from tensorflow.python.data.experimental.ops import scan_ops
  from tensorflow.python.data.experimental.ops import take_while_ops
  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.eager import test
  from tensorflow.python.framework import combinations
  from tensorflow.python.framework import dtypes
  from tensorflow.python.framework import errors
  from tensorflow.python.framework import ops
  from tensorflow.python.ops import gen_dataset_ops
  from tensorflow.python.ops import io_ops
  from tensorflow.python.ops import math_ops
  from tensorflow.python.ops import parsing_ops
  from tensorflow.python.ops import random_ops
  from tensorflow.python.ops import script_ops
  from tensorflow.python.ops import variables
  from tensorflow.python.platform import gfile
label_desc: Use image node_id 32 for calling the CheckpointTest obj's underlying member method code with example usage: obj.testStatefulExternalPolicy() and returns: unknown