code: def test_relay_reshape_legalize(ifm_shape, new_shape):
      ifm = relay.var("ifm", shape=ifm_shape, dtype="int8")
      reshape = relay.op.reshape(ifm, new_shape)
      func = relay.Function([ifm], reshape)
      mod = tvm.IRModule()
      mod["main"] = func
      mod = relay.transform.InferType()(mod)
  
      reshape_pattern_table = [
          (
              ethosu.ReshapeParams.composite_name,
              ethosu.reshape_pattern(),
              lambda pat: ethosu.ReshapeParams(pat).is_valid(),
          ),
      ]
  
      mod = partition_ethosu_by_table(mod, reshape_pattern_table)
      mod["tvmgen_default_ethos_u_main_0"] = dataflow_pattern.rewrite(
          legalize.ReshapeRewriter(),
          mod["tvmgen_default_ethos_u_main_0"],
      )
      mod["tvmgen_default_ethos_u_main_0"] = dataflow_pattern.rewrite(
          legalize.NoOpRewriter(), mod["tvmgen_default_ethos_u_main_0"]
      )
      mod = relay.transform.InferType()(mod)
  
      ext_func = mod["tvmgen_default_ethos_u_main_0"]
  
      identity = ext_func.body
      assert identity.op.name == "contrib.ethosu.identity"
  
      # check that the reshape is still there
      reshape = identity.args[0]
      assert reshape.op.name == "reshape"
  
      # check that identity's output shape matches reshape's output shape
      assert tuple(identity.checked_type.shape) == new_shape
  
imports: import pytest
  import math
  import numpy
  import tensorflow
  import tflite.Model
  import tvm
  from tvm import relay
  from tvm.relay.backend.contrib.ethosu import legalize, preprocess
  from tvm.relay import dataflow_pattern
  from tvm.relay.op.contrib import ethosu
  from tvm.relay.backend.contrib.ethosu import util, codegen
  from tvm.relay.build_module import bind_params_by_name
  from tvm.relay.frontend.tflite import get_pad_value
  from tvm.relay.expr_functor import ExprVisitor
  from .None import infra
label_desc: Use image node_id 18 for calling a global function with example usage: test_relay_reshape_legalize(ifm_shape, new_shape) without return types