code: def test_data_reorganize(self, cpu_only=False):
      def get_coreml_model_reorganize(X, params):
          eval = True
          mlmodel = None
          try:
              input_dim = X.shape[2:]
              input_features = [("data", datatypes.Array(*input_dim))]
              output_features = [("output", None)]
              builder = neural_network.NeuralNetworkBuilder(
                  input_features, output_features
              )
              builder.add_reorganize_data(
                  "reorg",
                  "data",
                  "output",
                  mode=params["mode"],
                  block_size=params["block_size"],
              )
              mlmodel = MLModel(builder.spec)
          except RuntimeError as e:
              print(e)
              eval = False
  
          return mlmodel, eval
  
      def get_tf_predictions_reorganize(X, params):
          Hin = params["H"]
          Win = params["W"]
          Cin = params["C"]
          with tf.Graph().as_default(), tf.Session() as sess:
              x = tf.placeholder(tf.float32, shape=(1, Hin, Win, Cin))
              if params["mode"] == "SPACE_TO_DEPTH":
                  y = tf.space_to_depth(x, params["block_size"])
              else:
                  y = tf.depth_to_space(x, params["block_size"])
              return sess.run(y, feed_dict={x: X})
  
      """
          Define Params
          """
      params_dict = dict(
          C=[1, 2, 8, 16, 15, 27],
          H=[2, 4, 6, 8, 10, 15, 21, 16],
          W=[2, 4, 6, 8, 10, 15, 21, 16],
          block_size=[2, 3, 4, 5],
          mode=["SPACE_TO_DEPTH", "DEPTH_TO_SPACE"],
      )
      params = [
          x for x in list(itertools.product(*params_dict.values()))
      ]
      all_candidates = [
          dict(zip(params_dict.keys(), x)) for x in params
      ]
      valid_params = []
      for pr in all_candidates:
          if pr["mode"] == "SPACE_TO_DEPTH":
              if (
                  pr["H"] % pr["block_size"] == 0
                  and pr["W"] % pr["block_size"] == 0
              ):
                  valid_params.append(pr)
          else:
              if pr["C"] % (pr["block_size"] ** 2) == 0:
                  valid_params.append(pr)
      print(
          "Total params to be tested: ",
          len(valid_params),
          "out of canditates: ",
          len(all_candidates),
      )
      """
          Test
          """
      failed_tests_compile = []
      for i in range(len(valid_params)):
          params = valid_params[i]
          # print("=========: ", params)
          # if i % 10 == 0: print("======== Testing {}/{}".format(str(i), str(len(valid_params))))
          X = np.random.rand(1, params["C"], params["H"], params["W"])
          tf_preds = get_tf_predictions_reorganize(
              np.transpose(X, [0, 2, 3, 1]), params
          )
          tf_preds = np.transpose(tf_preds, [0, 3, 1, 2])
          coreml_model, eval = get_coreml_model_reorganize(
              np.expand_dims(X, axis=0), params
          )
          if eval is False:
              failed_tests_compile.append(params)
          else:
              input_dict = {"data": np.expand_dims(X, axis=0)}
              ref_output_dict = {"output": tf_preds[0, :, :, :]}
              self._test_model(
                  input_dict,
                  ref_output_dict,
                  coreml_model,
                  cpu_only=cpu_only,
              )
  
      self.assertEqual(failed_tests_compile, [])
  
imports: from __future__ import print_function
  import unittest
  import numpy
  import coremltools.models.datatypes
  from coremltools.models import neural_network
  from coremltools.models import MLModel
  from coremltools.models.utils import _is_macos, _macos_version
  from coremltools._deps import _HAS_TF, MSG_TF1_NOT_FOUND
  import itertools
label_desc: Use image node_id 2 for calling the StressTest obj's underlying member method code with example usage: obj.test_data_reorganize(cpu_only) and returns: mlmodel,  eval, sess