code: def test_merge_lut_into_conv():
      """If an operator that has a LUT attribute is followed by an identity operator
      with LUT, we can merge the two operataors."""
  
      ifm = relay.var("x", shape=(1, 8, 8, 4), dtype="int8")
      lut1 = relay.const([i for i in range(256)], dtype="int8")
      lut2 = relay.const(
          [i for i in reversed(range(256))], dtype="int8"
      )
  
      def before():
          conv1 = infra.make_ethosu_conv2d(
              ifm, 4, 4, (3, 3), (1, 1), (1, 1), (1, 1)
          )
          id1 = infra.make_ethosu_identity(
              conv1, lut=lut1, activation="TANH"
          )
          conv2 = infra.make_ethosu_conv2d(
              id1, 4, 7, (2, 2), (1, 1), (1, 1), (1, 1)
          )
          id2 = infra.make_ethosu_identity(
              conv2, lut=lut2, activation="SIGMOID"
          )
  
          func = relay.Function(relay.analysis.free_vars(id2), id2)
          func = func.with_attr("Compiler", "ethos-u")
          mod = tvm.IRModule.from_expr(func)
          return mod
  
      def after():
          conv1 = infra.make_ethosu_conv2d(
              ifm,
              4,
              4,
              (3, 3),
              (1, 1),
              (1, 1),
              (1, 1),
              lut=lut1,
              activation="TANH",
          )
          conv2 = infra.make_ethosu_conv2d(
              conv1,
              4,
              7,
              (2, 2),
              (1, 1),
              (1, 1),
              (1, 1),
              lut=lut2,
              activation="SIGMOID",
          )
  
          func = relay.Function(relay.analysis.free_vars(conv2), conv2)
          func = func.with_attr("Compiler", "ethos-u")
          mod = tvm.IRModule.from_expr(func)
          mod = relay.transform.InferType()(mod)
          return mod
  
      mod = LUTsOptimizer()(before())
      mod = relay.transform.InferType()(mod)
  
      assert tvm.ir.structural_equal(mod, after())
  
file_path: tvm/tests/python/contrib/test_ethosu/test_lut_optimizer.py
imports: import pytest
  import tensorflow
  import numpy
  import tvm
  from tvm import relay
  from tvm.relay.backend.contrib.ethosu.codegen import LUTsOptimizer
  from tvm.relay.backend.contrib.ethosu.codegen import relay_to_tir
  from tvm.relay.op.contrib.ethosu import partition_for_ethosu
  from .None import infra
label_desc: Use image node_id 1 for calling a global function with example usage: test_merge_lut_into_conv() and returns: mod, mod