parameters: (self, dataset=None, components=None, element_spec=None)
docstring: Creates a new iterator from the given dataset.
  
      If `dataset` is not specified, the iterator will be created from the given
      tensor components and element structure. In particular, the alternative for
      constructing the iterator is used when the iterator is reconstructed from
      it `CompositeTensor` representation.
  
      Args:
        dataset: A `tf.data.Dataset` object.
        components: Tensor components to construct the iterator from.
        element_spec: A nested structure of `TypeSpec` objects that
          represents the type specification of elements of the iterator.
  
      Raises:
        ValueError: If `dataset` is not provided and either `components` or
          `element_spec` is not provided. Or `dataset` is provided and either
          `components` and `element_spec` is provided.
docstring_summary: Creates a new iterator from the given dataset.
docstring_tokens: Creates a new iterator from the given dataset .
function: def __init__(self, dataset=None, components=None, element_spec=None):
      """Creates a new iterator from the given dataset.
  
      If `dataset` is not specified, the iterator will be created from the given
      tensor components and element structure. In particular, the alternative for
      constructing the iterator is used when the iterator is reconstructed from
      it `CompositeTensor` representation.
  
      Args:
        dataset: A `tf.data.Dataset` object.
        components: Tensor components to construct the iterator from.
        element_spec: A nested structure of `TypeSpec` objects that
          represents the type specification of elements of the iterator.
  
      Raises:
        ValueError: If `dataset` is not provided and either `components` or
          `element_spec` is not provided. Or `dataset` is provided and either
          `components` and `element_spec` is provided.
      """
  
      error_message = "Either `dataset` or both `components` and "
      "`element_spec` need to be provided."
  
      self._device = context.context().device_name
  
      if dataset is None:
        if (components is None or element_spec is None):
          raise ValueError(error_message)
        # pylint: disable=protected-access
        self._element_spec = element_spec
        self._flat_output_types = structure.get_flat_tensor_types(
            self._element_spec)
        self._flat_output_shapes = structure.get_flat_tensor_shapes(
            self._element_spec)
        self._iterator_resource, self._deleter = components
        # Delete the resource when this object is deleted
        self._resource_deleter = IteratorResourceDeleter(
            handle=self._iterator_resource,
            device=self._device,
            deleter=self._deleter)
      else:
        if (components is not None or element_spec is not None):
          raise ValueError(error_message)
        if (_device_stack_is_empty() or
            context.context().device_spec.device_type != "CPU"):
          with ops.device("/cpu:0"):
            self._create_iterator(dataset)
        else:
          self._create_iterator(dataset)
function_tokens: def __init__ ( self , dataset = None , components = None , element_spec = None ) : error_message = "Either `dataset` or both `components` and " "`element_spec` need to be provided." self . _device = context . context ( ) . device_name if dataset is None : if ( components is None or element_spec is None ) : raise ValueError ( error_message ) # pylint: disable=protected-access self . _element_spec = element_spec self . _flat_output_types = structure . get_flat_tensor_types ( self . _element_spec ) self . _flat_output_shapes = structure . get_flat_tensor_shapes ( self . _element_spec ) self . _iterator_resource , self . _deleter = components # Delete the resource when this object is deleted self . _resource_deleter = IteratorResourceDeleter ( handle = self . _iterator_resource , device = self . _device , deleter = self . _deleter ) else : if ( components is not None or element_spec is not None ) : raise ValueError ( error_message ) if ( _device_stack_is_empty ( ) or context . context ( ) . device_spec . device_type != "CPU" ) : with ops . device ( "/cpu:0" ) : self . _create_iterator ( dataset ) else : self . _create_iterator ( dataset )