code: def test_infer_destination_from_source_ranks(topo_func):
      bf.init()
      size = bf.size()
      bf.set_topology(topo_func(size))
      topo = bf.load_topology()
      in_neighbors = bf.in_neighbor_ranks()
      out_neighbors = bf.out_neighbor_ranks()
  
      # Make the W into average rule.
      expected_W = (nx.to_numpy_array(topo) > 0).astype(float)
      expected_W /= expected_W.sum(axis=0)
  
      src_ranks, W = InferDestinationFromSourceRanks(
          src_ranks=in_neighbors, construct_adjacency_matrix=True
      )
      assert sorted(src_ranks) == out_neighbors
      np.testing.assert_allclose(W, expected_W)
  
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 1 for calling a global function with example usage: test_infer_destination_from_source_ranks(topo_func) without return types