class_docstr: This class tests all functions of the ArithmeticSharedTensor.
docstr: Test convolution of encrypted tensor with public/private tensors.
docstr_tok: ["Test","convolution","of","encrypted","tensor","with","public\/private","tensors","."]
code: def _conv2d(self, image_size, in_channels):
      """Test convolution of encrypted tensor with public/private tensors."""
      nbatches = [1, 3]
      kernel_sizes = [(1, 1), (2, 2), (2, 3)]
      ochannels = [1, 3, 6]
      paddings = [0, 1, (0, 1)]
      strides = [1, 2, (1, 2)]
      dilations = [1, 2]
      groupings = [1, 2]
  
      for func_name in ["conv2d", "conv_transpose2d"]:
          for kernel_type in [lambda x: x, ArithmeticSharedTensor]:
              for (
                  batches,
                  kernel_size,
                  out_channels,
                  padding,
                  stride,
                  dilation,
                  groups,
              ) in itertools.product(
                  nbatches,
                  kernel_sizes,
                  ochannels,
                  paddings,
                  strides,
                  dilations,
                  groupings,
              ):
                  # sample input:
                  input_size = (
                      batches,
                      in_channels * groups,
                      *image_size,
                  )
                  input = get_random_test_tensor(
                      size=input_size, is_float=True
                  )
  
                  # sample filtering kernel:
                  if func_name == "conv2d":
                      k_size = (
                          out_channels * groups,
                          in_channels,
                          *kernel_size,
                      )
                  else:
                      k_size = (
                          in_channels * groups,
                          out_channels,
                          *kernel_size,
                      )
                  kernel = get_random_test_tensor(
                      size=k_size, is_float=True
                  )
  
                  # perform filtering:
                  encr_matrix = ArithmeticSharedTensor(input)
                  encr_kernel = kernel_type(kernel)
                  encr_conv = getattr(encr_matrix, func_name)(
                      encr_kernel,
                      padding=padding,
                      stride=stride,
                      dilation=dilation,
                      groups=groups,
                  )
  
                  # check that result is correct:
                  reference = getattr(F, func_name)(
                      input,
                      kernel,
                      padding=padding,
                      stride=stride,
                      dilation=dilation,
                      groups=groups,
                  )
                  self._check(
                      encr_conv, reference, "%s failed" % func_name
                  )
  
imports: import itertools
  import logging
  import unittest
  import crypten
  import crypten.communicator
  import torch
  import torch.nn.functional
  from crypten.common.rng import generate_random_ring_element
  from crypten.common.tensor_types import is_float_tensor
  from crypten.common.util import count_wraps
  from crypten.mpc.primitives import ArithmeticSharedTensor
  from test.multiprocess_test_case import get_random_test_tensor, MultiProcessTestCase
label_desc: Use image node_id 26 for calling the TestArithmetic obj's underlying member method code with example usage: obj._conv2d(image_size, in_channels) without return types