code: def clip(expr, type_map):
      """Rewrite a clip op"""
      arg = expr.args[0]
      t = type_map[arg]
      amin = expr.attrs.a_min
      amax = expr.attrs.a_max
      scale = fold_constant(t.scale)
      z_p = fold_constant(t.zero_point)
      if (
          isinstance(scale, relay.expr.Constant)
          and scale.data.numpy().size == 1
          and isinstance(z_p, relay.expr.Constant)
          and z_p.data.numpy().size == 1
      ):
          scale = scale.data.numpy().item()
          z_p = z_p.data.numpy().item()
          new_min = int(amin / scale + z_p)
          new_max = int(amax / scale + z_p)
          out = relay.op.clip(arg, new_min, new_max)
      else:
          if not isinstance(amin, relay.expr.Constant):
              amin = relay.op.const(amin)
          if not isinstance(amax, relay.expr.Constant):
              amax = relay.op.const(amax)
  
          scale_shape = infer_shape(scale)
          if len(scale_shape) > 0 and scale_shape[0] > 1:
              b_shape = [1] * len(infer_shape(arg))
              b_shape[t.axis] = -1
              amin = relay.op.reshape(
                  relay.op.broadcast_to(amin, scale_shape), b_shape
              )
              amax = relay.op.reshape(
                  relay.op.broadcast_to(amax, scale_shape), b_shape
              )
          amin = relay.qnn.op.quantize(
              amin, scale, z_p, t.axis, t.dtype
          )
          amax = relay.qnn.op.quantize(
              amax, scale, z_p, t.axis, t.dtype
          )
          out = relay.op.minimum(
              relay.op.maximum(arg, fold_constant(amin)),
              fold_constant(amax),
          )
  
      return [out, t]
  
imports: import numpy
  import tvm
  from tvm import relay
  from tvm.ir import TensorAffineType, TupleAffineType
  from tvm.relay.qnn.op import canonicalizations
  from tvm.tir import bijective_layout
  from ..op import register_fake_quantization_to_integer, register_optional_fake_quantization_to_integer
label_desc: Use image node_id 20 for calling a global function with example usage: clip(expr, type_map) and returns: list