<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 """ Transposes tensors with leading dimensions. Leading dimensions in When leading dimensions are found, `transpose` method considers them as a single grouped element indexed by 0 in `perm` list. So, passing and you want to move leading dims between A and B dimensions. Dimension indices in permutation list can be negative or positive. Valid positive index. Example: a = tf.random.normal((1, 2, 3, 4, 5, 6)) sess.run(b).shape output> (6, 4, 1, 2, 3, 5) :param tensor: TensorFlow tensor. :param perm: List of permutation indices. :returns: TensorFlow tensor. """

    perm = copy.copy(perm)
    idx = perm.index(...)
    perm[idx] = 0

    rank = tf.rank(tensor)
    perm_tf = perm % rank

    leading_dims = tf.range(rank - len(perm) + 1)
    perm = tf.concat([perm_tf[:idx], leading_dims, perm_tf[idx+1:]], 0)
    return tf.transpose(tensor, perm)