class_docstr: Tests for basics.py
class_docstr_tok: ["Tests","for","basics.py"]
code: def test_in_out_neighbors_biring(self):
      bf.init()
      rank = bf.rank()
      size = bf.size()
      assert bf.set_topology(RingGraph(size))
      in_neighbors = bf.in_neighbor_ranks()
      out_neighbors = bf.out_neighbor_ranks()
  
      expected_in_neighbors = list(
          set(map(lambda x: x % size, [rank - 1, rank + 1]))
      )
      expected_out_neighbors = list(
          set(map(lambda x: x % size, [rank - 1, rank + 1]))
      )
  
      if size <= 1:
          expected_in_neighbors = []
          expected_out_neighbors = []
  
      assert sorted(in_neighbors) == expected_in_neighbors
      assert sorted(out_neighbors) == expected_out_neighbors
  
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 7 for calling the BasicsTests obj's underlying member method code with example usage: obj.test_in_out_neighbors_biring() without return types