code: def nhwc_to_format(x, data_format):
      """Converts a numpy array from NHWC format to `data_format`."""
      rank = len(x.shape)
      if data_format == "NCHW":
          return np.transpose(
              x, [0, rank - 1] + list(range(1, rank - 1))
          )
      elif data_format == "NHWC":
          return x
      else:
          raise ValueError("Unknown format {}".format(data_format))
  
imports: import platform
  import unittest
  import numpy
  import six
  from tensorflow.compiler.tests import xla_test
  from tensorflow.python.framework import dtypes
  from tensorflow.python.ops import array_ops
  from tensorflow.python.ops import array_ops_stack
  from tensorflow.python.ops import bitwise_ops
  from tensorflow.python.ops import gen_functional_ops
  from tensorflow.python.ops import gen_nn_ops
  from tensorflow.python.ops import math_ops
  from tensorflow.python.ops import nn_ops
  from tensorflow.python.platform import googletest
label_desc: Use image node_id 1 for calling a global function with example usage: nhwc_to_format(x, data_format) and returns: np, x