class_docstr: This class tests all functions of CUDALongTensor as well as its integration with MPCTensor.
class_docstr_tok: ["This","class","tests","all","functions","of","CUDALongTensor","as","well","as","its","integration","with","MPCTensor","."]
docstr: Test torch.gather on CUDALongTensor
docstr_tok: ["Test","torch.gather","on","CUDALongTensor"]
code: def test_torch_gather(self) -> None:
      """Test torch.gather on CUDALongTensor"""
      sizes = [(5, 5), (5, 5, 5), (5, 5, 5, 5)]
      for size in sizes:
          for dim in range(len(size)):
              tensor = get_random_test_tensor(size=size, is_float=False)
              index = get_random_test_tensor(size=size, is_float=False)
              index = index.abs().clamp(0, 4)
  
              t_cuda = CUDALongTensor(tensor)
              idx_cuda = CUDALongTensor(index)
  
              reference = tensor.gather(dim, index)
              result = t_cuda.gather(dim, idx_cuda)
              result2 = torch.gather(t_cuda, dim, idx_cuda)
  
              self._check_int(
                  result.cpu(),
                  reference,
                  f"gather failed with size {size}",
              )
              self._check_int(
                  result2.cpu(),
                  reference,
                  f"gather failed with size {size}",
              )
  
imports: import collections
  import itertools
  import logging
  import unittest
  import crypten
  import torch
  import torch.nn
  import torch.nn.functional
  from crypten.config import cfg
  from crypten.cuda import CUDALongTensor
  from test.multiprocess_test_case import get_random_test_tensor, MultiProcessTestCase
  from test.test_mpc import TestMPC
label_desc: Use image node_id 23 for calling the TestCUDA obj's underlying member method code with example usage: obj.test_torch_gather() without return types