code: def _expand_dims_under_batch_dim(tensor, new_rank):
      """Adds size-1 dimensions below the first until `tensor` has `new_rank`."""
      if not tf.is_tensor(tensor):
          return tensor
      ones = tf.ones([new_rank - tf.rank(tensor)], dtype=tf.int32)
      shape = tf.shape(input=tensor)
      new_shape = tf.concat([shape[:1], ones, shape[1:]], axis=0)
      return tf.reshape(tensor, new_shape)
  
imports: import collections
  import functools
  import numpy
  import tensorflow.compat.v1
  import tensorflow.compat.v2
  from tensorflow_probability.python import random
  from tensorflow_probability.python.experimental import auto_batching
  from tensorflow_probability.python.math import gradient
  from tensorflow_probability.python.mcmc import kernel
  from tensorflow_probability.python.util.seed_stream import SeedStream
label_desc: Use image node_id 8 for calling a global function with example usage: _expand_dims_under_batch_dim(tensor, new_rank) and returns: tf, tensor