code: def create_topo_comms(comm):
      size = comm.Get_size()
      rank = comm.Get_rank()
      # Cartesian
      n = int(size**1 / 2.0)
      m = int(size**1 / 3.0)
      if m * m * m == size:
          dims = [m, m, m]
      elif n * n == size:
          dims = [n, n]
      else:
          dims = [size]
      periods = [True] * len(dims)
      yield comm.Create_cart(dims, periods=periods)
      # Graph
      index, edges = [0], []
      for i in range(size):
          pos = index[-1]
          index.append(pos + 2)
          edges.append((i - 1) % size)
          edges.append((i + 1) % size)
      yield comm.Create_graph(index, edges)
      # Dist Graph
      sources = [(rank - 2) % size, (rank - 1) % size]
      destinations = [(rank + 1) % size, (rank + 2) % size]
      yield comm.Create_dist_graph_adjacent(sources, destinations)
  
imports: from mpi4py import MPI
  import mpiunittest
label_desc: Use image node_id 1 for calling a global function with example usage: create_topo_comms(comm) without return types