code: def test_correctness():  # noqa: C901
      def voxel_test(data, mask, max_blk_edge, rad):
          comm = MPI.COMM_WORLD
          rank = comm.rank
  
          (dim0, dim1, dim2) = mask.shape
  
          # Initialize dataset with known pattern
          for subj in data:
              if subj is not None:
                  for tr in range(subj.shape[3]):
                      for d1 in range(dim0):
                          for d2 in range(dim1):
                              for d3 in range(dim2):
                                  subj[d1, d2, d3, tr] = np.array(
                                      [d1, d2, d3, tr]
                                  )
  
          sl = Searchlight(sl_rad=rad, max_blk_edge=max_blk_edge)
          sl.distribute(data, mask)
          sl.broadcast(MaskRadBcast(mask, rad))
          global_outputs = sl.run_searchlight(voxel_test_sfn)
  
          if rank == 0:
              for d0 in range(rad, global_outputs.shape[0] - rad):
                  for d1 in range(rad, global_outputs.shape[1] - rad):
                      for d2 in range(
                          rad, global_outputs.shape[2] - rad
                      ):
                          if mask[d0, d1, d2]:
                              assert np.array_equal(
                                  np.array(global_outputs[d0, d1, d2]),
                                  np.array([d0, d1, d2]),
                              )
  
      def block_test(data, mask, max_blk_edge, rad):
          comm = MPI.COMM_WORLD
          rank = comm.rank
  
          (dim0, dim1, dim2) = mask.shape
  
          # Initialize dataset with known pattern
          for subj in data:
              if subj is not None:
                  for tr in range(subj.shape[3]):
                      for d1 in range(dim0):
                          for d2 in range(dim1):
                              for d3 in range(dim2):
                                  subj[d1, d2, d3, tr] = np.array(
                                      [d1, d2, d3, tr]
                                  )
  
          sl = Searchlight(sl_rad=rad, max_blk_edge=max_blk_edge)
          sl.distribute(data, mask)
          sl.broadcast(mask)
          global_outputs = sl.run_block_function(block_test_sfn)
  
          if rank == 0:
              for d0 in range(rad, global_outputs.shape[0] - rad):
                  for d1 in range(rad, global_outputs.shape[1] - rad):
                      for d2 in range(
                          rad, global_outputs.shape[2] - rad
                      ):
                          if mask[d0, d1, d2]:
                              assert np.array_equal(
                                  np.array(global_outputs[d0, d1, d2]),
                                  np.array([d0, d1, d2, 0]),
                              )
  
      # Create dataset
      def do_test(dim0, dim1, dim2, ntr, nsubj, max_blk_edge, rad):
          comm = MPI.COMM_WORLD
          rank = comm.rank
          size = comm.size
          mask = np.random.choice([True, False], (dim0, dim1, dim2))
          data = [
              np.empty((dim0, dim1, dim2, ntr), dtype=object)
              if i % size == rank
              else None
              for i in range(0, nsubj)
          ]
          voxel_test(data, mask, max_blk_edge, rad)
          block_test(data, mask, max_blk_edge, rad)
  
      do_test(
          dim0=7, dim1=5, dim2=9, ntr=5, nsubj=1, max_blk_edge=4, rad=1
      )
      do_test(
          dim0=7, dim1=5, dim2=9, ntr=5, nsubj=1, max_blk_edge=4, rad=0
      )
      do_test(
          dim0=7, dim1=5, dim2=9, ntr=5, nsubj=5, max_blk_edge=4, rad=1
      )
      do_test(
          dim0=1, dim1=5, dim2=9, ntr=5, nsubj=5, max_blk_edge=4, rad=1
      )
      do_test(
          dim0=0, dim1=10, dim2=8, ntr=5, nsubj=5, max_blk_edge=4, rad=1
      )
      do_test(
          dim0=7, dim1=5, dim2=9, ntr=5, nsubj=1, max_blk_edge=4, rad=2
      )
      do_test(
          dim0=7, dim1=5, dim2=9, ntr=5, nsubj=1, max_blk_edge=4, rad=3
      )
  
file_path: brainiak/tests/searchlight/test_searchlight.py
imports: from collections import namedtuple
  import numpy
  from mpi4py import MPI
  import conftest
  from brainiak.searchlight.searchlight import Searchlight
  from brainiak.searchlight.searchlight import Diamond, Ball
label_desc: Use image node_id 11 for calling a global function with example usage: test_correctness() without return types