code: def _best_effort_input_batch_size(flat_input):
      """Get static input batch size if available, with fallback to the dynamic one.
  
      Args:
        flat_input: An iterable of time major input Tensors of shape `[max_time,
          batch_size, ...]`. All inputs should have compatible batch sizes.
  
      Returns:
        The batch size in Python integer if available, or a scalar Tensor otherwise.
  
      Raises:
        ValueError: if there is any input with an invalid shape.
      """
      for input_ in flat_input:
          shape = input_.shape
          if shape.rank is None:
              continue
          if shape.rank < 2:
              raise ValueError(
                  "Expected input tensor %s to have rank at least 2"
                  % input_
              )
          batch_size = shape.dims[1].value
          if batch_size is not None:
              return batch_size
      # Fallback to the dynamic batch size of the first input.
      return tf.shape(input=flat_input[0])[1]
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import tensorflow
  from tf_agents.utils import common
label_desc: Use image node_id 3 for calling a global function with example usage: _best_effort_input_batch_size(flat_input) and returns: tf, batch_size