class_docstr: Tests for bluefog/torch/mpi_ops.py on one-sided communication.
code: def test_win_update_with_default_weights(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]
  
      bf.set_topology(topology_util.StarGraph(size), is_weighted=True)
  
      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_create_{}_{}".format(dim, dtype)
          is_created = bf.win_create(tensor, window_name)
          assert (
              is_created
          ), "bf.win_create do not create window object successfully."
  
          # Note the buffers store the copy of original value so they will not change.
          tensor.mul_(2)
          if rank == 0:
              expected_result = (
                  rank * 2 / size + rank * (size - 1) / size
              )
          else:
              expected_result = rank / size + rank * 2 * (1 - 1 / size)
  
          sync_result = bf.win_update(window_name)
          assert (
              list(sync_result.shape) == [DIM_SIZE] * dim
          ), "bf.win_update (weighted) produces wrong shape tensor."
          assert (
              sync_result.data - expected_result
          ).abs().max() < EPSILON, (
              "bf.win_update (weighted) produces wrong tensor value "
              + "[{0}-{1}]!={2} at rank {2}.".format(
                  sync_result.min(), sync_result.max(), rank
              )
          )
      assert bf.win_free()
  
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 9 for calling the WinOpsTests obj's underlying member method code with example usage: obj.test_win_update_with_default_weights() without return types