class_docstr: Base test class for checkpointing datasets.
class_docstr_tok: ["Base","test","class","for","checkpointing","datasets","."]
code: def _add_iterator_ops_to_collection(
      self, init_op, get_next, ds_fn, sparse_tensors=False
  ):
      ops.add_to_collection("iterator_ops", init_op)
      # `get_next` may be a tuple e.g. in TensorSliceDataset. Since Collections
      # do not support tuples we flatten the tensors and restore the shape in
      # `_get_iterator_ops_from_collection`.
      if (
          sparse_tensors
      ):  # specific for deprecated `from_sparse_tensor_slices`.
          ops.add_to_collection("iterator_ops", get_next.indices)
          ops.add_to_collection("iterator_ops", get_next.values)
          ops.add_to_collection("iterator_ops", get_next.dense_shape)
          return
  
      get_next_list = nest.flatten(get_next)
      for i, output_class in enumerate(
          nest.flatten(self._get_output_classes(ds_fn))
      ):
          if output_class is sparse_tensor.SparseTensor:
              ops.add_to_collection(
                  "iterator_ops", get_next_list[i].indices
              )
              ops.add_to_collection(
                  "iterator_ops", get_next_list[i].values
              )
              ops.add_to_collection(
                  "iterator_ops", get_next_list[i].dense_shape
              )
          else:
              ops.add_to_collection("iterator_ops", get_next_list[i])
  
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 14 for calling the CheckpointTestBase obj's underlying member method code with example usage: obj._add_iterator_ops_to_collection(init_op, get_next, ds_fn, sparse_tensors) without return types