code: def fake_quantize_per_tensor_affine(
      g: jit_utils.GraphContext,
      inputs,
      scale,
      zero_point,
      quant_min=-128,
      quant_max=127,
  ):
      # NOTE: (0, 127) is allowed as special case. PyTorch restricts activations to be in the range (0, 127).
      #   https://github.com/pytorch/pytorch/blob/b34b192d6b97325c9f78e5995c48c8498ede34bd/torch/ao/quantization/observer.py#L1422
      if (quant_min, quant_max) not in [
          (0, 255),
          (-128, 127),
          (0, 127),
      ]:
          raise errors.SymbolicValueError(
              "For (quant_min, quant_max), ONNX allows only (0, 127), (0, 255) and (-128, 127). "
              f"Got ({quant_min}, {quant_max})",
              inputs,
          )
      if quant_min == 0:
          zero_point = g.op(
              "Cast", zero_point, to_i=_C_onnx.TensorProtoDataType.UINT8
          )
      else:
          zero_point = g.op(
              "Cast", zero_point, to_i=_C_onnx.TensorProtoDataType.INT8
          )
      if (
          _type_utils.JitScalarType.from_value(
              scale, _type_utils.JitScalarType.UNDEFINED
          )
          != _type_utils.JitScalarType.FLOAT
      ):
          scale = g.op(
              "Cast", scale, to_i=_C_onnx.TensorProtoDataType.FLOAT
          )
      quantized = g.op("QuantizeLinear", inputs, scale, zero_point)
      if (quant_min, quant_max) == (0, 127):
          quantized = g.op(
              "Clip",
              quantized,
              opset9.unused(g),
              g.op(
                  "Constant",
                  value_t=torch.tensor(127, dtype=torch.uint8),
              ),
          )
      return g.op("DequantizeLinear", quantized, scale, zero_point)
  
imports: import functools
  import torch
  import torch._C._onnx
  from torch.onnx import _constants, _type_utils, errors, symbolic_helper, symbolic_opset11, symbolic_opset9, utils
  from torch.onnx._internal import _beartype, jit_utils, registration
label_desc: Use image node_id 14 for calling a global function with example usage: fake_quantize_per_tensor_affine(g, inputs, scale, zero_point, quant_min, quant_max) and returns: g