class_docstr: This class tests all functions of the ArithmeticSharedTensor.
docstr: Test scatter/scatter_add function of encrypted tensor
docstr_tok: ["Test","scatter\/scatter_add","function","of","encrypted","tensor"]
code: def test_scatter(self) -> None:
      """Test scatter/scatter_add function of encrypted tensor"""
      funcs = ["scatter", "scatter_", "scatter_add", "scatter_add_"]
      sizes = [(5, 5), (5, 5, 5), (5, 5, 5, 5)]
      for func in funcs:
          for size in sizes:
              for tensor_type in [lambda x: x, ArithmeticSharedTensor]:
                  for dim in range(len(size)):
                      tensor1 = get_random_test_tensor(
                          size=size, is_float=True
                      )
                      tensor2 = get_random_test_tensor(
                          size=size, is_float=True
                      )
                      index = get_random_test_tensor(
                          size=size, is_float=False
                      )
                      index = index.abs().clamp(0, 4)
                      encrypted = ArithmeticSharedTensor(tensor1)
                      encrypted2 = tensor_type(tensor2)
                      reference = getattr(tensor1, func)(
                          dim, index, tensor2
                      )
                      encrypted_out = getattr(encrypted, func)(
                          dim, index, encrypted2
                      )
                      private = tensor_type == ArithmeticSharedTensor
                      self._check(
                          encrypted_out,
                          reference,
                          "%s %s failed"
                          % ("private" if private else "public", func),
                      )
                      if func.endswith("_"):
                          # Check in-place scatter/scatter-add modified input
                          self._check(
                              encrypted,
                              reference,
                              "%s %s failed to modify input"
                              % (
                                  "private" if private else "public",
                                  func,
                              ),
                          )
                      else:
                          # Check original is not modified
                          self._check(
                              encrypted,
                              tensor1,
                              "%s %s unintendedly modified input"
                              % (
                                  "private" if private else "public",
                                  func,
                              ),
                          )
  
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 12 for calling the TestArithmetic obj's underlying member method code with example usage: obj.test_scatter() without return types