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: Computes the static batch dimension of a dataset if it can be determined.
  
  Given the RebatchDataset parameters, determines the batch dimension of this
  dataset statically. Returns None if this cannot be determined or is
  variable.
  
  Returns:
    An integer representing the batch dimension of the dataset. If it cannot
    be determined statically, returns None.
  
  Raises:
    ValueError: The batch_sizes parameter is malformed, input_dataset is
    not batched, or input_dataset batch sizes are incompatible with each
    other.
docstr_tok: ["Computes","the","static","batch","dimension","of","a","dataset","if","it","can","be","determined",".","Given","the","RebatchDataset","parameters",",","determines","the","batch","dimension","of","this","dataset","statically",".","Returns","None","if","this","can","not","be","determined","or","is","variable",".","Returns",":","An","integer","representing","the","batch","dimension","of","the","dataset",".","If","it","can","not","be","determined","statically",",","returns","None",".","Raises",":","ValueError",":","The","batch_sizes","parameter","is","malformed",",","input_dataset","is","not","batched",",","or","input_dataset","batch","sizes","are","incompatible","with","each","other","."]
code: def _compute_static_batch_dim(self):
      """Computes the static batch dimension of a dataset if it can be determined.
  
      Given the RebatchDataset parameters, determines the batch dimension of this
      dataset statically. Returns None if this cannot be determined or is
      variable.
  
      Returns:
        An integer representing the batch dimension of the dataset. If it cannot
        be determined statically, returns None.
  
      Raises:
        ValueError: The batch_sizes parameter is malformed, input_dataset is
        not batched, or input_dataset batch sizes are incompatible with each
        other.
      """
      new_batch_dim = tensor_util.constant_value(self._batch_sizes)
      if new_batch_dim is None:
          return None
  
      if isinstance(new_batch_dim, np.ndarray):
          if len(new_batch_dim.shape) == 1:
              if np.all(new_batch_dim == new_batch_dim[0]):
                  new_batch_dim = new_batch_dim[0]
              else:
                  return None
          elif len(new_batch_dim.shape) > 1:
              raise ValueError(
                  f"Invalid `batch_sizes`. Expected `batch_sizes` to be a scalar or "
                  f"a vector. Received `batch_sizes` of rank "
                  f"{len(new_batch_dim.shape)}."
              )
  
      if self._may_form_partial_batches(new_batch_dim):
          return None
  
      return new_batch_dim
  
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 2 for calling the _RebatchDataset obj's underlying member method code with example usage: obj._compute_static_batch_dim() and returns: new_batch_dim, None, None, None