class_docstr: A `Dataset` that rebatches elements from its input into new batch sizes.
  
  `_RebatchDataset(input_dataset, batch_sizes)` is functionally equivalent to
  `input_dataset.unbatch().batch(N)`, where the value of N cycles through the
  `batch_sizes` input list. The elements produced by this dataset have the same
  rank as the elements of the input dataset.
class_docstr_tok: ["A","`","Dataset","`","that","rebatches","elements","from","its","input","into","new","batch","sizes",".","`","_RebatchDataset","(","input_dataset",",","batch_sizes",")","`","is","functionally","equivalent","to","`","input_dataset.unbatch","(",")",".batch","(","N",")","`",",","where","the","value","of","N","cycles","through","the","`","batch_sizes","`","input","list",".","The","elements","produced","by","this","dataset","have","the","same","rank","as","the","elements","of","the","input","dataset","."]
docstr: Returns whether this dataset may form partial batches.
docstr_tok: ["Returns","whether","this","dataset","may","form","partial","batches","."]
code: def _may_form_partial_batches(self, desired_batch_size):
      """Returns whether this dataset may form partial batches."""
      if tensor_util.constant_value(self._drop_remainder):
          return False
  
      def get_batch_dim(type_spec):
          try:
              shape = (
                  type_spec._to_legacy_output_shapes()
              )  # pylint: disable=protected-access
          except NotImplementedError:
              return None
          if not isinstance(shape, tensor_shape.TensorShape):
              return None
          if shape.rank is None:
              return None
          if len(shape) < 1:
              raise ValueError(
                  "Invalid `batch_sizes`. Expected dataset with "
                  "rank of >= 1 but found a dataset with "
                  "scalar elements. Fix the issue by adding the `batch` "
                  "transformation to the dataset."
              )
          return shape.dims[0].value
  
      input_batch_dims = [
          get_batch_dim(ts)
          for ts in nest.flatten(
              dataset_ops.get_structure(self._input_dataset)
          )
      ]
      known_input_batch_dims = [
          d for d in input_batch_dims if d is not None
      ]
  
      if not known_input_batch_dims:
          return True
  
      known_input_batch_dims = np.asarray(known_input_batch_dims)
      if not np.all(
          known_input_batch_dims == known_input_batch_dims[0]
      ):
          raise ValueError(
              f"Invalid `input_dataset.` The batch dimension of component 0 "
              f"is {known_input_batch_dims[0]}, while the batch dimension "
              f"of component i is {known_input_batch_dims}."
          )
  
      return known_input_batch_dims[0] % desired_batch_size != 0
  
file_path: tensorflow-upstream/tensorflow/python/data/ops/rebatch_op.py
imports: import numpy
  from tensorflow.python.data.ops import dataset_ops
  from tensorflow.python.data.util import nest
  from tensorflow.python.framework import dtypes
  from tensorflow.python.framework import ops
  from tensorflow.python.framework import tensor_shape
  from tensorflow.python.framework import tensor_util
  from tensorflow.python.ops import gen_experimental_dataset_ops
label_desc: Use image node_id 3 for calling the _RebatchDataset obj's underlying member method code with example usage: obj._may_form_partial_batches(desired_batch_size) and returns: unknown, False, shape, True, None, None, None