class_docstr: FATECommunicator is a wrapper around the FATE communicator.
class_docstr_tok: ["FATECommunicator","is","a","wrapper","around","the","FATE","communicator","."]
code: def __init__(
      self,
      ctx: Context,
      main_group: CommunicateGroup,
      rank_to_party,
      rank,
      world_size,
  ):
      assert (
          rank in rank_to_party
      ), f"rank {rank} not in rank_to_party: {rank_to_party}"
      assert (
          len(rank_to_party) == world_size
      ), f"rank_to_party size {len(rank_to_party)} != world_size {world_size}"
      for i in range(world_size):
          assert (
              i in rank_to_party
          ), f"rank {i} not in rank_to_party: {rank_to_party}"
      self.ctx = ctx
      self.rank = rank
      self.rank_to_party = rank_to_party
      self.world_size = world_size
      self._pool = trace.instrument_thread_pool_executor(
          ThreadPoolExecutor(max_workers=world_size)
      )
      self.main_group = main_group
  
imports: import functools
  import logging
  import sys
  import timeit
  from concurrent.futures import ThreadPoolExecutor
  import torch
  from torch.distributed import ReduceOp
  from torch.distributed import ReduceOp
  from fate.arch.context import Context, NS, Parties
  from fate.arch import trace
  from typing import List
label_desc: Use image node_id 1 to create a new Communicator object  with example: obj = Communicator(ctx, main_group, rank_to_party, rank, world_size)