code: def GetExp2DynamicSendRecvMachineRanks(
      world_size: int, local_size: int, self_rank: int, local_rank: int
  ) -> Iterator[Tuple[List[int], List[int]]]:
      """
      A utility function to generate 1-outgoing send machine id and corresponding recieving
      machine id(s) for Exponentia-2 topology.
  
      Args:
          world_size (int): the size of all nodes; world_size = num_machines * nodes_per_machine
          local_size (int): number of nodes in each machine
          self_rank (int): The self rank.
          local_rank (int): The self local rank.
  
      Yields:
          Iterator[Tuple[List[int], List[int]]]: send_machine_ids, recv_machine_ids.
  
      Warning:
          This function should be used under homogeneous enviroment only, i.e. all machines have
          the same number of local processes.
      """
      assert (
          self_rank % local_size
      ) == local_rank, (
          "It should be used under homogeneous environment only."
      )
      assert (
          world_size % local_size
      ) == 0, "It should be used under homogeneous environment only."
      assert (
          world_size > local_size
      ), "It should be used under at least two machines case."
  
      machine_id = self_rank // local_size
      machine_size = world_size // local_size
      exp_2_size = (
          int(np.log2(machine_size - 1)) if machine_size > 1 else 0
      )
      index = 0
      while True:
          machine_dist = 2 ** (index % (exp_2_size + 1))
          send_machine_rank = (machine_id + machine_dist) % machine_size
          recv_machine_ranks = (
              machine_id - machine_dist
          ) % machine_size
          yield [send_machine_rank], [recv_machine_ranks]
          index += 1
  
imports: from typing import List, Tuple, Dict, Iterator, Optional
  import math
  import numpy
  import networkx
label_desc: Use image node_id 14 for calling a global function with example usage: GetExp2DynamicSendRecvMachineRanks(world_size, local_size, _rank, local_rank) without return types