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(
                  "Input tensor should have rank >= 2. Received input="
                  f"{input_} of rank {shape.rank}"
              )
          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 array_ops.shape(flat_input[0])[1]
  
imports: from tensorflow.python.eager import context
  from tensorflow.python.framework import constant_op
  from tensorflow.python.framework import dtypes
  from tensorflow.python.framework import ops
  from tensorflow.python.framework import tensor
  from tensorflow.python.framework import tensor_shape
  from tensorflow.python.framework import tensor_util
  from tensorflow.python.ops import array_ops
  from tensorflow.python.ops import array_ops_stack
  from tensorflow.python.ops import cond
  from tensorflow.python.ops import control_flow_assert
  from tensorflow.python.ops import control_flow_util
  from tensorflow.python.ops import control_flow_util_v2
  from tensorflow.python.ops import math_ops
  from tensorflow.python.ops import rnn_cell_impl
  from tensorflow.python.ops import tensor_array_ops
  from tensorflow.python.ops import variable_scope
  from tensorflow.python.ops import while_loop
  from tensorflow.python.util import deprecation
  from tensorflow.python.util import dispatch
  from tensorflow.python.util import nest
  from tensorflow.python.util.tf_export import tf_export
label_desc: Use image node_id 2 for calling a global function with example usage: _best_effort_input_batch_size(flat_input) and returns: array_ops, batch_size