code: def dataset_iterator(dataset):
      """Constructs a `Dataset` iterator.
  
      The method used to construct the iterator is conditioned on whether Graph mode
      is enabled. `dataset_iterator` and `get_next` are useful when we need to
      construct an iterator and iterate through it inside a `tensorflow.function`.
  
      Args:
        dataset: a `tf.data.Dataset`.
  
      Returns:
        A `tf.data.Iterator` if Graph mode is enabled; a tf.data.EagerIterator if
        in eager mode.
      """
      if tf.executing_eagerly():
          return iter(dataset)
      try:
          iterator = tf.compat.v1.data.make_one_shot_iterator(dataset)
      except ValueError:
          iterator = tf.compat.v1.data.make_initializable_iterator(
              dataset
          )
      return iterator
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import copy
  import functools
  import inspect
  from absl import logging
  import numpy
  import six
  import tensorflow
  from tf_agents.utils import common
  from tensorflow.python.util import tf_decorator
label_desc: Use image node_id 11 for calling a global function with example usage: dataset_iterator(dataset) and returns: iterator, iter