def try_to_transform(
        self, op: Operation, dequantize_x: Operation, dequantize_y: Operation, quantize_z: Operation
    ) -> bool:
        """
        given dequantize_x, dequantize_y, quantize_z, transform by
            z_fp = (x - zp_x) * s_x/s_y .op. (y - zp_y) * 1.0
            z = z_fp / (s_z/s_y) - zp_z

        See the class doc for details
        """
        block = quantize_z.enclosing_block

        new_s_x, new_s_z = self.try_to_divide(dequantize_x, dequantize_y, quantize_z)
        # if s_y cannot be used to divide, then swap x and y and try again
        if new_s_x is None and new_s_z is None:
            dequantize_x, dequantize_y = dequantize_y, dequantize_x
            new_s_x, new_s_z = self.try_to_divide(dequantize_x, dequantize_y, quantize_z)
            # after swap, if still cannot divide, then give up
            if new_s_x is None and new_s_z is None:
                return False

        def convert_mil_float_dtype_to_np(mil_dtype):
            if mil_dtype == types.fp16 or mil_dtype == "float16":
                np_dtype = np.float16
            else:
                np_dtype = np.float32
            return np_dtype

        new_s_x_dtype = convert_mil_float_dtype_to_np(dequantize_x.scale.val.dtype)
        new_s_y_dtype = convert_mil_float_dtype_to_np(dequantize_y.scale.val.dtype)
        new_s_z_dtype = convert_mil_float_dtype_to_np(quantize_z.scale.val.dtype)

        # insert normalized new_dequantize_x and new_dequantize_y before op
        new_dequantize_x = mb.dequantize(
            input=dequantize_x.input,
            scale=new_s_x_dtype(new_s_x),
            zero_point=dequantize_x.zero_point,
            axis=dequantize_x.axis,
            before_op=op,
        )
        new_dequantize_y = mb.dequantize(
            input=dequantize_y.input,
            scale=new_s_y_dtype(1)
            if dequantize_y.axis is None
            else np.full(dequantize_y.scale.val.shape, 1.0),
            zero_point=dequantize_y.zero_point,
            axis=dequantize_y.axis,
            before_op=op,
        )

        # insert normalized new_quantize_z before quantize_z
        new_quantize_z = mb.quantize(
            input=quantize_z.input,
            scale=new_s_z_dtype(new_s_z),
            zero_point=quantize_z.zero_point,
            axis=quantize_z.axis,
            output_dtype=quantize_z.output_dtype,
            before_op=quantize_z,
        )
        if not (
            # replace dequantize_x and dequantize_y with the normalized ones
            # in the range of (new_dequantize_x, op] and (new_dequantize_y, op]
            # in case dequantize_x and dequantize_y also feed to other ops
            # which should not get altered by this transformation
            block.try_replace_uses_of_var_after_op(
                anchor_op=new_dequantize_x.op,
                end_op=op,
                old_var=dequantize_x.outputs[0],
                new_var=new_dequantize_x,
            )
            and block.try_replace_uses_of_var_after_op(
                anchor_op=new_dequantize_y.op,
                end_op=op,
                old_var=dequantize_y.outputs[0],
                new_var=new_dequantize_y,
            )
            # replace quantize_z with the normalized one
            and block.try_replace_uses_of_var_after_op(
                anchor_op=quantize_z, old_var=quantize_z.outputs[0], new_var=new_quantize_z
            )
        ):
            return False

        # remove quantize_z here, but not dequantize_x and dequantize_y, since:
        # * all uses of quantize_z has been replaced with the normalized one
        # * dequantize_x and dequantize_y may feed to multiple ops, which are not replaced
        #   (if not, then pass dead_code_elimination will eliminate them)
        block.remove_ops([quantize_z])

        return True

        given dequantize_x, dequantize_y, quantize_z, transform by
            z_fp = (x - zp_x) * s_x/s_y .op. (y - zp_y) * 1.0
            z = z_fp / (s_z/s_y) - zp_z

        See the class doc for details
        
coremltools/converters/mil/mil/passes/defs/optimize_quantization.py