parameters: (self, dataset, output_types, output_shapes=None)
docstring: Creates a new dataset with the given output types and shapes.
  
      The given `dataset` must have a structure that is convertible:
      * `dataset.output_types` must be the same as `output_types` module nesting.
      * Each shape in `dataset.output_shapes` must be compatible with each shape
        in `output_shapes` (if given).
  
      Note: This helper permits "unsafe casts" for shapes, equivalent to using
      `tf.Tensor.set_shape()` where domain-specific knowledge is available.
  
      Args:
        dataset: A `Dataset` object.
        output_types: A nested structure of `tf.DType` objects.
        output_shapes: (Optional.) A nested structure of `tf.TensorShape` objects.
          If omitted, the shapes will be inherited from `dataset`.
  
      Raises:
        ValueError: If either `output_types` or `output_shapes` is not compatible
          with the structure of `dataset`.
docstring_summary: Creates a new dataset with the given output types and shapes.
docstring_tokens: Creates a new dataset with the given output types and shapes .
function: def __init__(self, dataset, output_types, output_shapes=None):
      """Creates a new dataset with the given output types and shapes.
  
      The given `dataset` must have a structure that is convertible:
      * `dataset.output_types` must be the same as `output_types` module nesting.
      * Each shape in `dataset.output_shapes` must be compatible with each shape
        in `output_shapes` (if given).
  
      Note: This helper permits "unsafe casts" for shapes, equivalent to using
      `tf.Tensor.set_shape()` where domain-specific knowledge is available.
  
      Args:
        dataset: A `Dataset` object.
        output_types: A nested structure of `tf.DType` objects.
        output_shapes: (Optional.) A nested structure of `tf.TensorShape` objects.
          If omitted, the shapes will be inherited from `dataset`.
  
      Raises:
        ValueError: If either `output_types` or `output_shapes` is not compatible
          with the structure of `dataset`.
      """
      super(_RestructuredDataset, self).__init__()
      self._dataset = dataset
  
      # Validate that the types are compatible.
      output_types = nest.map_structure(dtypes.as_dtype, output_types)
      flat_original_types = nest.flatten(dataset.output_types)
      flat_new_types = nest.flatten(output_types)
      if flat_original_types != flat_new_types:
        raise ValueError(
            "Dataset with output types %r cannot be restructured to have output "
            "types %r" % (dataset.output_types, output_types))
  
      self._output_types = output_types
  
      if output_shapes is None:
        # Inherit shapes from the original `dataset`.
        self._output_shapes = nest.pack_sequence_as(output_types,
                                                    nest.flatten(
                                                        dataset.output_shapes))
      else:
        # Validate that the shapes are compatible.
        nest.assert_same_structure(output_types, output_shapes)
        flat_original_shapes = nest.flatten(dataset.output_shapes)
        flat_new_shapes = nest.flatten_up_to(output_types, output_shapes)
  
        for original_shape, new_shape in zip(flat_original_shapes,
                                             flat_new_shapes):
          if not original_shape.is_compatible_with(new_shape):
            raise ValueError(
                "Dataset with output shapes %r cannot be restructured to have "
                "incompatible output shapes %r" % (dataset.output_shapes,
                                                   output_shapes))
        self._output_shapes = nest.map_structure_up_to(
            output_types, tensor_shape.as_shape, output_shapes)
function_tokens: def __init__ ( self , dataset , output_types , output_shapes = None ) : super ( _RestructuredDataset , self ) . __init__ ( ) self . _dataset = dataset # Validate that the types are compatible. output_types = nest . map_structure ( dtypes . as_dtype , output_types ) flat_original_types = nest . flatten ( dataset . output_types ) flat_new_types = nest . flatten ( output_types ) if flat_original_types != flat_new_types : raise ValueError ( "Dataset with output types %r cannot be restructured to have output " "types %r" % ( dataset . output_types , output_types ) ) self . _output_types = output_types if output_shapes is None : # Inherit shapes from the original `dataset`. self . _output_shapes = nest . pack_sequence_as ( output_types , nest . flatten ( dataset . output_shapes ) ) else : # Validate that the shapes are compatible. nest . assert_same_structure ( output_types , output_shapes ) flat_original_shapes = nest . flatten ( dataset . output_shapes ) flat_new_shapes = nest . flatten_up_to ( output_types , output_shapes ) for original_shape , new_shape in zip ( flat_original_shapes , flat_new_shapes ) : if not original_shape . is_compatible_with ( new_shape ) : raise ValueError ( "Dataset with output shapes %r cannot be restructured to have " "incompatible output shapes %r" % ( dataset . output_shapes , output_shapes ) ) self . _output_shapes = nest . map_structure_up_to ( output_types , tensor_shape . as_shape , output_shapes )