class_docstr: Tests for bluefog/torch/mpi_ops.py on one-sided communication.
code: def test_asscoicated_with_p_random_test(self):
      size = bf.size()
      rank = bf.rank()
      dtypes = [torch.FloatTensor, torch.DoubleTensor]
      # Current, nccl version hasn't supported the associated with p yet.
      if TEST_ON_GPU and not bf.nccl_built():
          dtypes += [torch.cuda.FloatTensor, torch.cuda.DoubleTensor]
      dims = [1]
      bf.turn_on_win_ops_with_associated_p()
      for dtype, dim in itertools.product(dtypes, dims):
          tensor = torch.FloatTensor(*([23] * dim)).fill_(1)
          tensor = self.cast_and_place(tensor, dtype)
          window_name = "win_asscoicate_with_p_random_{}_{}".format(
              dim, dtype
          )
          bf.win_create(tensor, window_name, zero_init=True)
          for _ in range(10):
              random_weights = np.random.rand(
                  len(bf.out_neighbor_ranks()) + 1
              )
              random_weights /= random_weights.sum()
              self_weight = random_weights[-1]
              dst_weights = {
                  r: random_weights[i]
                  for i, r in enumerate(bf.out_neighbor_ranks())
              }
              bf.win_put(
                  tensor,
                  self_weight=self_weight,
                  dst_weights=dst_weights,
                  name=window_name,
                  require_mutex=True,
              )
              bf.win_update(name=window_name, require_mutex=True)
              bf.win_accumulate(
                  tensor,
                  name=window_name,
                  require_mutex=True,
                  self_weight=self_weight,
                  dst_weights=dst_weights,
              )
              bf.win_update_then_collect(name=window_name)
          bf.barrier()
          bf.win_update_then_collect(name=window_name)
          associated_p = bf.win_associated_p(name=window_name)
          # Because the associated p should operate the same as tensor always
          # the following assert should be true no matter what order is excuted.
          assert abs(associated_p - tensor.data[0]) < EPSILON
  
      bf.turn_off_win_ops_with_associated_p()
  
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 25 for calling the WinOpsTests obj's underlying member method code with example usage: obj.test_asscoicated_with_p_random_test() without return types