class_docstr: This class tests the crypten.nn package.
class_docstr_tok: ["This","class","tests","the","crypten.nn","package","."]
docstr: Tests the global average pool module with fixed 4-d test tensors
code: def test_global_avg_pool_module(self):
      """
      Tests the global average pool module with fixed 4-d test tensors
      """
      # construct basic input
      base_tensor = torch.tensor([[2, 1], [3, 0]])
      all_init = []
      for i in range(-2, 3):
          all_init.append(torch.add(base_tensor, i))
      init_tensor = torch.stack(all_init, dim=2)
      init_tensor = init_tensor.unsqueeze(-1)
      reference = base_tensor.unsqueeze(-1).unsqueeze(-1)
  
      # create module
      encr_module = crypten.nn.GlobalAveragePool().encrypt()
      self.assertTrue(encr_module.encrypted, "module not encrypted")
  
      # check correctness for a variety of input sizes
      for i in range(1, 10):
          input = init_tensor.repeat(1, 1, i, i)
          encr_input = crypten.cryptensor(input)
          encr_output = encr_module(encr_input)
          self._check(
              encr_output, reference, "GlobalAveragePool failed"
          )
  
imports: import copy
  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.config import cfg
  from crypten.encoder import FixedPointEncoder
  from test.multiprocess_test_case import get_random_linear, get_random_test_tensor, MultiProcessTestCase, onehot
label_desc: Use image node_id 6 for calling the TestNN obj's underlying member method code with example usage: obj.test_global_avg_pool_module() without return types