code: def _test_conv_api_impl(
      self,
      qconv_fn,
      conv_fn,
      batch_size,
      in_channels_per_group,
      input_feature_map_size,
      out_channels_per_group,
      groups,
      kernel_size,
      stride,
      padding,
      dilation,
      X_scale,
      X_zero_point,
      W_scale,
      W_zero_point,
      Y_scale,
      Y_zero_point,
      use_bias,
      use_channelwise,
  ):
      for i in range(len(kernel_size)):
          assume(
              input_feature_map_size[i] + 2 * padding[i]
              >= dilation[i] * (kernel_size[i] - 1) + 1
          )
      (X, X_q, W, W_q, b) = _make_conv_test_input(
          batch_size,
          in_channels_per_group,
          input_feature_map_size,
          out_channels_per_group,
          groups,
          kernel_size,
          X_scale,
          X_zero_point,
          W_scale,
          W_zero_point,
          use_bias,
          use_channelwise,
      )
  
      Y_exp = conv_fn(X, W, b, stride, padding, dilation, groups)
      Y_exp = torch.quantize_per_tensor(
          Y_exp,
          scale=Y_scale,
          zero_point=Y_zero_point,
          dtype=torch.quint8,
      )
      Y_act = qconv_fn(
          X_q,
          W_q,
          b,
          stride,
          padding,
          dilation,
          groups,
          padding_mode="zeros",
          scale=Y_scale,
          zero_point=Y_zero_point,
      )
  
      # Make sure the results match
      # assert_array_almost_equal compares using the following formula:
      #     abs(desired-actual) < 1.5 * 10**(-decimal)
      # (https://docs.scipy.org/doc/numpy/reference/generated/numpy.testing.assert_almost_equal.html)
      # We use decimal = 0 to ignore off-by-1 differences between reference
      # and test. Off-by-1 differences arise due to the order of round and
      # zero_point addition operation, i.e., if addition followed by round is
      # used by reference and round followed by addition is used by test, the
      # results may differ by 1.
      # For example, the result of round(2.5) + 1 is 3 while round(2.5 + 1) is
      # 4 assuming the rounding mode is round-to-nearest, ties-to-even.
      np.testing.assert_array_almost_equal(
          Y_exp.int_repr().numpy(), Y_act.int_repr().numpy(), decimal=0
      )
  
file_path: pytorch/test/quantization/core/test_quantized_functional.py
imports: import torch
  import torch.ao.nn.quantized.functional
  import torch.nn.functional
  import numpy
  from hypothesis import assume, given
  from hypothesis import strategies
  from torch.testing._internal.common_quantization import QuantizationTestCase, _make_conv_test_input
  from torch.testing._internal.common_quantized import override_quantized_engine
  from torch.testing._internal.common_utils import IS_PPC, TEST_WITH_UBSAN
label_desc: Use image node_id 2 for calling the TestQuantizedFunctionalOps obj's underlying member method code with example usage: obj._test_conv_api_impl(qconv_fn, conv_fn, batch_size, in_channels_per_group, input_feature_map_size, out_channels_per_group, groups, kernel_size, stride, padding, dilation, X_scale, X_zero_point, W_scale, W_zero_point, Y_scale, Y_zero_point, use_bias, use_channelwise) without return types