code: def test_image_resize2d_convert_layout():
      def _test_image_resize_convert_layout_nchw_to_nhwc():
          def before():
              x = relay.var("x", shape=(1, 2, 4, 4))
              y = relay.image.resize2d(x, (8, 8))
              y = relay.Function([x], y)
              return y
  
          def expected():
              x = relay.var("x", shape=(1, 2, 4, 4))
              x = relay.layout_transform(x, "NCHW", "NHWC")
              y = relay.image.resize2d(x, (8, 8), layout="NHWC")
              y = relay.layout_transform(y, "NHWC", "NCHW")
              y = relay.Function(relay.analysis.free_vars(y), y)
              return y
  
          a = before()
          a = run_opt_pass(
              a, transform.ConvertLayout({"image.resize2d": ["NHWC"]})
          )
          b = run_opt_pass(expected(), transform.InferType())
  
          assert tvm.ir.structural_equal(a, b), "Actual = \n" + str(a)
  
      def _test_image_resize_convert_layout_nhwc_to_nchw():
          def before():
              x = relay.var("x", shape=(1, 4, 4, 2))
              y = relay.image.resize2d(x, (8, 8), layout="NHWC")
              y = relay.Function([x], y)
              return y
  
          def expected():
              x = relay.var("x", shape=(1, 4, 4, 2))
              x = relay.layout_transform(x, "NHWC", "NCHW")
              y = relay.image.resize2d(x, (8, 8), layout="NCHW")
              y = relay.layout_transform(y, "NCHW", "NHWC")
              y = relay.Function(relay.analysis.free_vars(y), y)
              return y
  
          a = before()
          a = run_opt_pass(
              a, transform.ConvertLayout({"image.resize2d": ["NCHW"]})
          )
          b = run_opt_pass(expected(), transform.InferType())
  
          assert tvm.ir.structural_equal(a, b), "Actual = \n" + str(a)
  
      _test_image_resize_convert_layout_nchw_to_nhwc()
      _test_image_resize_convert_layout_nhwc_to_nchw()
  
imports: import pytest
  import tvm
  from tvm import relay, te
  from tvm.relay import analysis, transform
  from tvm.relay.op import op
  from tvm.relay.op import register_alter_op_layout
  from tvm.relay.quantize._annotate import attach_simulated_quantize, QAnnotateKind
  from tvm.relay.transform.infer_layout_utils import InferCorrectLayoutOutput
label_desc: Use image node_id 40 for calling a global function with example usage: test_image_resize2d_convert_layout() and returns: y, y, y, y