code: def test_tflite_hard_swish(ifm_shape):
      dtype = "int8"
  
      def create_tflite_graph():
          class Model(tf.Module):
              @tf.function
              def tf_function(self, x):
                  op = tf.keras.layers.Lambda(
                      lambda x: x
                      * tf.keras.activations.relu(
                          x + 3.0, max_value=6.0
                      )
                      / 6.0
                  )(x)
                  return op
  
          model = Model()
          concrete_func = model.tf_function.get_concrete_function(
              tf.TensorSpec(ifm_shape, tf.float32)
          )
  
          def representative_dataset():
              for _ in range(100):
                  data = np.random.rand(*tuple(ifm_shape))
                  yield [data.astype(np.float32)]
  
          converter = tf.lite.TFLiteConverter.from_concrete_functions(
              [concrete_func]
          )
          converter.optimizations = [tf.lite.Optimize.DEFAULT]
          converter.representative_dataset = representative_dataset
          converter.target_spec.supported_ops = [
              tf.lite.OpsSet.TFLITE_BUILTINS_INT8
          ]
          converter.inference_input_type = tf.int8
          converter.inference_output_type = tf.int8
          tflite_model = converter.convert()
  
          return tflite_model
  
      tflite_graph = create_tflite_graph()
      tflite_model = tflite.Model.Model.GetRootAsModel(tflite_graph, 0)
  
      mod, params = relay.frontend.from_tflite(
          tflite_model,
          shape_dict={"input": ifm_shape},
          dtype_dict={"input": dtype},
      )
  
      mod = ethosu.partition_for_ethosu(mod, params)
      mod["tvmgen_default_ethos_u_main_0"] = dataflow_pattern.rewrite(
          legalize.HardSwishRewriter(),
          mod["tvmgen_default_ethos_u_main_0"],
      )
      mod = relay.transform.InferType()(mod)
  
      func_body = mod["tvmgen_default_ethos_u_main_0"].body
      assert func_body.op.name == "contrib.ethosu.identity"
      assert func_body.attrs.activation == "LUT"
      assert tuple(func_body.args[0].checked_type.shape) == (ifm_shape)
      assert tuple(func_body.args[1].checked_type.shape) == (256,)
  
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 40 for calling a global function with example usage: test_tflite_hard_swish(ifm_shape) and returns: tflite_model, op