class_docstr: Tests for bluefog/torch/mpi_ops.py on one-sided communication.
docstr: Test that the window create and free objects correctly.
code: def test_win_create_and_sync_and_free(self):
      """Test that the window create and free objects correctly."""
      size = bf.size()
      rank = bf.rank()
      # OpenMPI implementation seems won't allow win_create on size 1.
      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]
  
      # By default, we use exponential two ring topology.
      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."
  
          sync_result = bf.win_update(window_name)
          assert (
              list(sync_result.shape) == [DIM_SIZE] * dim
          ), "bf.win_update produce wrong shape tensor."
          assert sync_result.data.min() == rank, (
              "bf.win_update produces wrong tensor value "
              + "{0}!={1} at rank {1}.".format(
                  sync_result.data.min(), rank
              )
          )
          assert sync_result.data.max() == rank, (
              "bf.win_update produces wrong tensor value "
              + "{0}!={1} at rank {1}.".format(
                  sync_result.data.max(), rank
              )
          )
  
      for dtype, dim in itertools.product(dtypes, dims):
          window_name = "win_create_{}_{}".format(dim, dtype)
          is_freed = bf.win_free(window_name)
          assert (
              is_freed
          ), "bf.win_free do not free window object successfully."
  
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 5 for calling the WinOpsTests obj's underlying member method code with example usage: obj.test_win_create_and_sync_and_free() without return types