code: def primitive_alltoall(sess, node, output_dim, group_size, rank):
      if not is_partition(output_dim):
          return
      shape = node.shape
      if len(shape) < 2 or shape[output_dim] % group_size != 0:
          return
      for i in range(len(node.shape)):
          if rank is not None and i != rank:
              continue
          if shape[i] % group_size != 0 or output_dim == i:
              continue
          try:
              source_dims, num_partitions = node.parser.emit_dims_by_id(
                  i
              )
              connectors = dict(
                  [
                      (
                          inp,
                          sess.backend.link(
                              "$",
                              -1,
                              None,
                              is_param=(
                                  node.inputs[inp].op_type == "param"
                              ),
                          ),
                      )
                      for inp in source_dims
                      if is_replicas(source_dims[inp])
                  ]
              )
              connectors[""] = sess.backend.link("$", i, output_dim)
              yield (i, source_dims, connectors)
          except NotImplementedError:
              continue
  
file_path: tutel/tutel/parted/patterns.py
imports: from .solver import register_primitive
label_desc: Use image node_id 8 for calling a global function with example usage: primitive_alltoall(sess, node, output_dim, group_size, rank) without return types