class_docstr: Tests for bluefog/torch/mpi_ops.py on one-sided communication.
code: def test_win_update_then_collect(self):
      size = bf.size()
      rank = bf.rank()
      if size <= 1:
          fname = inspect.currentframe().f_code.co_name
          warnings.warn("Skip {} due to size 1".format(fname))
          return
      dtypes = [torch.FloatTensor, torch.DoubleTensor]
      if TEST_ON_GPU:
          dtypes += [torch.cuda.FloatTensor, torch.cuda.DoubleTensor]
  
      indegree = int(np.ceil(np.log2(size)))
      expected_result = rank * (indegree + 1)
  
      dims = [1, 2, 3]
      for dtype, dim in itertools.product(dtypes, dims):
          tensor = (
              torch.FloatTensor(*([DIM_SIZE] * dim)).fill_(1).mul_(rank)
          )
          tensor = self.cast_and_place(tensor, dtype)
          window_name = "win_update_collect_{}_{}".format(dim, dtype)
  
          bf.win_create(tensor, window_name)
  
          # After the collect ops, the neighbro tensor will become zero.
          # So second win_update_then_collect should produce the same value.
          for _ in range(2):
              collect_tensor = bf.win_update_then_collect(window_name)
  
              assert (
                  list(collect_tensor.shape) == [DIM_SIZE] * dim
              ), "bf.win_update_then_collect produces wrong shape tensor."
              assert (
                  collect_tensor.data - expected_result
              ).abs().max() < EPSILON, (
                  "bf.win_update_then_collect produces wrong tensor value "
                  + "[{0}-{1}]!={2} at rank {2}.".format(
                      collect_tensor.min(), collect_tensor.max(), rank
                  )
              )
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import inspect
  import itertools
  import time
  import warnings
  import unittest
  from bluefog.common import topology_util
  import bluefog.torch
  import torch
  import numpy
label_desc: Use image node_id 10 for calling the WinOpsTests obj's underlying member method code with example usage: obj.test_win_update_then_collect() without return types