code: def _get_leftmost_dim_size(x, name=None):
      """Returns the size of the left most dimension, statically if possible."""
      with tf.name_scope(name or "get_leftmost_dim_size"):
          x = tf.convert_to_tensor(value=x, name="x")
          if x.shape.ndims is None:
              # If tf.shape(x) is scalar, the [:1] will produce the empty list, whose
              # reduce_prod is 1 as desired.  Otherwise, the [:1] will select the first
              # dimension, and reduce_prod will not alter it.
              return tf.reduce_prod(input_tensor=tf.shape(input=x)[:1])
          if x.shape.ndims == 0:
              return 1
          leftmost = tf.compat.dimension_value(x.shape[0])
          return (
              leftmost if leftmost is not None else tf.shape(input=x)[0]
          )
  
imports: import collections
  import contextlib
  import six
  import tensorflow.compat.v1
  import tensorflow.compat.v2
  from tensorflow_probability.python.experimental.auto_batching import instructions
  from tensorflow_probability.python.experimental.auto_batching import xla
  from tensorflow_probability.python.internal import dtype_util
  from tensorflow.python.ops import control_flow_util
label_desc: Use image node_id 4 for calling a global function with example usage: _get_leftmost_dim_size(x, name) and returns: unknown, tf, int