class_docstr: Tests for basics.py
class_docstr_tok: ["Tests","for","basics.py"]
code: def test_set_and_load_topology(self):
      bf.init()
      size = bf.size()
      if size == 4:
          expected_topology = nx.DiGraph(
              np.array(
                  [
                      [1 / 3.0, 1 / 3.0, 1 / 3.0, 0.0],
                      [0.0, 1 / 3.0, 1 / 3.0, 1 / 3.0],
                      [1 / 3.0, 0.0, 1 / 3.0, 1 / 3.0],
                      [1 / 3.0, 1 / 3.0, 0.0, 1 / 3.0],
                  ]
              )
          )
      elif size == 1:
          expected_topology = nx.DiGraph(np.array([[1.0]]))
      else:
          expected_topology = ExponentialGraph(size)
      topology = bf.load_topology()
      assert isinstance(topology, nx.DiGraph)
      assert IsTopologyEquivalent(expected_topology, topology)
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import inspect
  import os
  import warnings
  import unittest
  import numpy
  import networkx
  import pytest
  import torch
  from common import mpi_env_rank_and_size
  import bluefog.torch
  from bluefog.torch import ExponentialGraph, RingGraph, StarGraph, MeshGrid2DGraph, FullyConnectedGraph
  from bluefog.torch import IsTopologyEquivalent, InferDestinationFromSourceRanks, InferSourceFromDestinationRanks
label_desc: Use image node_id 5 for calling the BasicsTests obj's underlying member method code with example usage: obj.test_set_and_load_topology() without return types