code: def rearrange(src, dst, t):
      """Reorder dimensions of tensor according to formula."""
  
      new_indices = ""
      for i in dst:
          if i not in src:
              new_indices += i
      new_src = src + new_indices
      new_t = tf.reshape(
          t,
          ps.concat(
              [ps.shape(t), ps.ones(len(new_indices), dtype=tf.int32)],
              axis=0,
          ),
      )
      formula = "{}->{}".format(new_src, dst)
      # It is safe to use ordinary `einsum` here as no summations
      # are performed.
      return tf.einsum(formula, new_t)
  
file_path: probability/tensorflow_probability/python/experimental/marginalize/logeinsumexp.py
imports: import opt_einsum
  import tensorflow.compat.v2
  from tensorflow_probability.python.internal import prefer_static
label_desc: Use image node_id 3 for calling a global function with example usage: rearrange(src, dst, t) and returns: tf