code: def test_fold_qnn_const():
      def before():
          # QNN op with 2 constant arguments.
          add = relay.qnn.op.add(
              relay.const(
                  np.ones((2, 3), dtype="uint8"), dtype="uint8"
              ),
              relay.const(
                  np.ones((2, 3), dtype="uint8"), dtype="uint8"
              ),
              lhs_scale=relay.const(2.0),
              lhs_zero_point=relay.const(0),
              rhs_scale=relay.const(2.0),
              rhs_zero_point=relay.const(0),
              output_scale=relay.const(1.0),
              output_zero_point=relay.const(0),
          )
          # QNN op with 1 constant and 1 non-constant arguments.
          a = relay.var("a", shape=[2, 3], dtype="float32")
          dense = relay.qnn.op.dense(
              relay.qnn.op.quantize(
                  a, relay.const(1.0), relay.const(0)
              ),
              add,
              input_zero_point=relay.const(0),
              kernel_zero_point=relay.const(0),
              input_scale=relay.const(2.0),
              kernel_scale=relay.const(2.0),
              units=None,
          )
          # QNN op with 2 non-constant arguments.
          b = relay.var("b", shape=[2], dtype="float32")
          bias = relay.qnn.op.add(
              dense,
              relay.qnn.op.quantize(
                  b, relay.const(1.0), relay.const(0), out_dtype="int32"
              ),
              lhs_scale=relay.const(2.0),
              lhs_zero_point=relay.const(0),
              rhs_scale=relay.const(2.0),
              rhs_zero_point=relay.const(0),
              output_scale=relay.const(1.0),
              output_zero_point=relay.const(0),
          )
          return relay.Function([a, b], bias)
  
      def expected():
          a = relay.var("a", shape=[2, 3], dtype="float32")
          dense = relay.qnn.op.dense(
              relay.qnn.op.quantize(
                  a, relay.const(1.0), relay.const(0)
              ),
              relay.const(
                  np.array([[4, 4, 4], [4, 4, 4]], dtype="uint8"),
                  dtype="uint8",
              ),
              input_zero_point=relay.const(0),
              kernel_zero_point=relay.const(0),
              input_scale=relay.const(2.0),
              kernel_scale=relay.const(2.0),
              units=None,
          )
          b = relay.var("b", shape=[2], dtype="float32")
          bias = relay.qnn.op.add(
              dense,
              relay.qnn.op.quantize(
                  b, relay.const(1.0), relay.const(0), out_dtype="int32"
              ),
              lhs_scale=relay.const(2.0),
              lhs_zero_point=relay.const(0),
              rhs_scale=relay.const(2.0),
              rhs_zero_point=relay.const(0),
              output_scale=relay.const(1.0),
              output_zero_point=relay.const(0),
          )
          return relay.Function([a, b], bias)
  
      # Nothing changed after applying FoldConstant
      a = run_opt_pass(before(), transform.FoldConstant())
      b = run_opt_pass(before(), transform.InferType())
      tvm.ir.assert_structural_equal(a, b)
  
      # Fold QNN constants
      a = run_opt_pass(before(), transform.FoldConstant(fold_qnn=True))
      b = run_opt_pass(expected(), transform.InferType())
      tvm.ir.assert_structural_equal(a, b)
  
imports: import numpy
  import tvm
  import tvm.testing
  from tvm import relay
  from tvm.relay.backend import Executor
  from tvm.relay import transform
  from tvm.relay.build_module import bind_params_by_name
  from tvm.relay.testing import run_infer_type, create_workload
label_desc: Use image node_id 15 for calling a global function with example usage: test_fold_qnn_const() and returns: relay, relay