code: def _transpose_if_necessary(tensor, perm):
      """Like transpose(), but avoids creating a new tensor if possible."""
      if perm != list(range(len(perm))):
          return array_ops.transpose(tensor, perm=perm)
      else:
          return tensor
  
imports: import collections
  import functools
  import re
  import string
  import numpy
  import opt_einsum
  from tensorflow.compiler.tf2xla.ops import gen_xla_ops
  from tensorflow.python.framework import ops
  from tensorflow.python.framework import tensor
  from tensorflow.python.framework import tensor_shape
  from tensorflow.python.ops import array_ops
  from tensorflow.python.ops import control_flow_ops
  from tensorflow.python.ops import gen_linalg_ops
  from tensorflow.python.ops import gen_special_math_ops
  from tensorflow.python.ops import math_ops
  from tensorflow.python.platform import tf_logging
  from tensorflow.python.util import deprecation
  from tensorflow.python.util import dispatch
  from tensorflow.python.util.tf_export import tf_export
label_desc: Use image node_id 25 for calling a global function with example usage: _transpose_if_necessary(tensor, perm) and returns: array_ops, tensor