code: def add_rewrite(ref_call, new_args, ctx):
      """Rewrite function for add."""
      if quantize_context().check_to_skip(ref_call):
          return None
  
      lhs_expr, lhs_kind = _get_expr_kind(new_args[0])
      rhs_expr, rhs_kind = _get_expr_kind(new_args[1])
  
      if lhs_kind is None and rhs_kind is None:
          # trivial case
          return None
  
      if lhs_kind is None and rhs_kind is not None:
          # quantize lhs to INPUT field if it is normal expression
          assert rhs_kind in [
              QAnnotateKind.INPUT,
              QAnnotateKind.ACTIVATION,
          ]
          lhs_expr = attach_simulated_quantize(
              lhs_expr, QAnnotateKind.INPUT
          )
          expr = _forward_op(ref_call, [lhs_expr, rhs_expr])
          return QAnnotateExpr(expr, QAnnotateKind.ACTIVATION)
  
      if lhs_kind is not None and rhs_kind is None:
          if _analysis.check_constant(rhs_expr):
              # - introduced by batch_norm: add(out, const)
              rhs_expr = attach_simulated_quantize(
                  rhs_expr, QAnnotateKind.WEIGHT
              )
          else:
              rhs_expr = attach_simulated_quantize(
                  rhs_expr, QAnnotateKind.INPUT
              )
          expr = _forward_op(ref_call, [lhs_expr, rhs_expr])
          return QAnnotateExpr(expr, QAnnotateKind.ACTIVATION)
  
      if lhs_kind is not None and rhs_kind is not None:
          if (
              lhs_kind == QAnnotateKind.INPUT
              and rhs_kind == QAnnotateKind.INPUT
          ):
              expr = _forward_op(ref_call, [lhs_expr, rhs_expr])
              return QAnnotateExpr(expr, QAnnotateKind.ACTIVATION)
          if (
              lhs_kind == QAnnotateKind.ACTIVATION
              and rhs_kind == QAnnotateKind.ACTIVATION
          ):
              rhs_expr = attach_simulated_quantize(
                  rhs_expr, QAnnotateKind.INPUT
              )
              expr = _forward_op(ref_call, [lhs_expr, rhs_expr])
              return QAnnotateExpr(expr, QAnnotateKind.ACTIVATION)
          if (
              lhs_kind == QAnnotateKind.ACTIVATION
              and rhs_kind == QAnnotateKind.INPUT
          ) or (
              lhs_kind == QAnnotateKind.INPUT
              and rhs_kind == QAnnotateKind.ACTIVATION
          ):
              expr = _forward_op(ref_call, [lhs_expr, rhs_expr])
              return QAnnotateExpr(expr, QAnnotateKind.ACTIVATION)
      raise ValueError()
  
imports: import warnings
  from tvm import topi
  import tvm._ffi
  from tvm.relay.op import op
  from ..None import expr
  from ..None import analysis
  from ..None import op
  from .None import _quantize
  from .quantize import QAnnotateKind, current_qconfig, quantize_context
  from .quantize import _forward_op
label_desc: Use image node_id 10 for calling a global function with example usage: add_rewrite(ref_call, new_args, ctx) and returns: None, None, QAnnotateExpr, QAnnotateExpr, QAnnotateExpr, QAnnotateExpr, QAnnotateExpr