parameters: (batch_size)
return_statement: return _apply_fn
docstring: A batching transformation that omits the final small batch (if present).
  
    Like @{tf.data.Dataset.batch}, this transformation combines
    consecutive elements of this dataset into batches. However, if the batch
    size does not evenly divide the input dataset size, this transformation will
    drop the final smaller element.
  
    The following example illustrates the difference between this
    transformation and `Dataset.batch()`:
  
    ```python
    dataset = tf.data.Dataset.range(200)
    batched = dataset.apply(tf.contrib.data.batch_and_drop_remainder(128))
    print(batched.output_shapes)  # ==> "(128,)" (the batch dimension is known)
    ```
  
    By contrast, `dataset.batch(128)` would yield a two-element dataset with
    shapes `(128,)` and `(72,)`, so the batch dimension would not be statically
    known.
  
    Args:
      batch_size: A `tf.int64` scalar `tf.Tensor`, representing the number of
          consecutive elements of this dataset to combine in a single batch.
  
    Returns:
      A `Dataset` transformation function, which can be passed to
      @{tf.data.Dataset.apply}
docstring_summary: A batching transformation that omits the final small batch (if present).
docstring_tokens: A batching transformation that omits the final small batch ( if present ) .
function: def batch_and_drop_remainder(batch_size):
    """A batching transformation that omits the final small batch (if present).
  
    Like @{tf.data.Dataset.batch}, this transformation combines
    consecutive elements of this dataset into batches. However, if the batch
    size does not evenly divide the input dataset size, this transformation will
    drop the final smaller element.
  
    The following example illustrates the difference between this
    transformation and `Dataset.batch()`:
  
    ```python
    dataset = tf.data.Dataset.range(200)
    batched = dataset.apply(tf.contrib.data.batch_and_drop_remainder(128))
    print(batched.output_shapes)  # ==> "(128,)" (the batch dimension is known)
    ```
  
    By contrast, `dataset.batch(128)` would yield a two-element dataset with
    shapes `(128,)` and `(72,)`, so the batch dimension would not be statically
    known.
  
    Args:
      batch_size: A `tf.int64` scalar `tf.Tensor`, representing the number of
          consecutive elements of this dataset to combine in a single batch.
  
    Returns:
      A `Dataset` transformation function, which can be passed to
      @{tf.data.Dataset.apply}
    """
  
    def _apply_fn(dataset):
      """Function from `Dataset` to `Dataset` that applies the transformation."""
      tensor_batch_size = ops.convert_to_tensor(
          batch_size, dtype=dtypes.int64, name="batch_size")
  
      batched = dataset.batch(tensor_batch_size)
      flattened = _RestructuredDataset(batched,
                                       tuple(nest.flatten(batched.output_types)))
  
      def _predicate(*xs):
        """Return `True` if this element is a full batch."""
        # Extract the dynamic batch size from the first component of the flattened
        # batched element.
        first_component = xs[0]
        first_component_batch_size = array_ops.shape(
            first_component, out_type=dtypes.int64)[0]
  
        return math_ops.equal(first_component_batch_size, tensor_batch_size)
  
      filtered = flattened.filter(_predicate)
  
      maybe_constant_batch_size = tensor_util.constant_value(tensor_batch_size)
  
      def _set_first_dimension(shape):
        return shape.merge_with(
            tensor_shape.vector(maybe_constant_batch_size).concatenate(shape[1:]))
  
      known_shapes = nest.map_structure(_set_first_dimension,
                                        batched.output_shapes)
      return _RestructuredDataset(filtered, batched.output_types, known_shapes)
  
    return _apply_fn
function_tokens: def batch_and_drop_remainder ( batch_size ) : def _apply_fn ( dataset ) : """Function from `Dataset` to `Dataset` that applies the transformation.""" tensor_batch_size = ops . convert_to_tensor ( batch_size , dtype = dtypes . int64 , name = "batch_size" ) batched = dataset . batch ( tensor_batch_size ) flattened = _RestructuredDataset ( batched , tuple ( nest . flatten ( batched . output_types ) ) ) def _predicate ( * xs ) : """Return `True` if this element is a full batch.""" # Extract the dynamic batch size from the first component of the flattened # batched element. first_component = xs [ 0 ] first_component_batch_size = array_ops . shape ( first_component , out_type = dtypes . int64 ) [ 0 ] return math_ops . equal ( first_component_batch_size , tensor_batch_size ) filtered = flattened . filter ( _predicate ) maybe_constant_batch_size = tensor_util . constant_value ( tensor_batch_size ) def _set_first_dimension ( shape ) : return shape . merge_with ( tensor_shape . vector ( maybe_constant_batch_size ) . concatenate ( shape [ 1 : ] ) ) known_shapes = nest . map_structure ( _set_first_dimension , batched . output_shapes ) return _RestructuredDataset ( filtered , batched . output_types , known_shapes ) return _apply_fn