class_docstr: Base test class for checkpointing datasets.
class_docstr_tok: ["Base","test","class","for","checkpointing","datasets","."]
code: def _build_graph(self, ds_fn, sparse_tensors=False):
      dataset = ds_fn()
      iterator = dataset_ops.make_initializable_iterator(dataset)
      external_state_policy = (
          dataset.options().experimental_external_state_policy
      )
      saveable = contrib_iterator_ops.make_saveable_from_iterator(
          iterator, external_state_policy=external_state_policy
      )
      ops.add_to_collection(ops.GraphKeys.SAVEABLE_OBJECTS, saveable)
      init_op = iterator.initializer
      if sparse_tensors:
          get_next = sparse_tensor.SparseTensor(*iterator.get_next())
      else:
          get_next = iterator.get_next()
      self._add_iterator_ops_to_collection(
          init_op, get_next, ds_fn, sparse_tensors
      )
      saver = saver_lib.Saver(allow_empty=True)
      return init_op, get_next, saver
  
imports: import os
  import numpy
  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 iterator_ops
  from tensorflow.python.data.ops import dataset_ops
  from tensorflow.python.data.ops import options
  from tensorflow.python.eager import context
  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.framework import sparse_tensor
  from tensorflow.python.framework import tensor
  from tensorflow.python.ops import lookup_ops
  from tensorflow.python.ops import variables
  from tensorflow.python.ops.ragged import ragged_tensor_value
  from tensorflow.python.platform import gfile
  from tensorflow.python.platform import test
  from tensorflow.python.training import saver
  from tensorflow.python.util import nest
label_desc: Use image node_id 13 for calling the CheckpointTestBase obj's underlying member method code with example usage: obj._build_graph(ds_fn, sparse_tensors) and returns: init_op,  get_next,  saver