code: def _sync_seeds(
      ctx: "Context", generators, next_seed, local_seed, global_seed
  ):
      """
      Sends random seed to next party, recieve seed from prev. party, and broadcast global seed
  
      After seeds are distributed. One seed is created for each party to coordinate seeds
      across cuda devices.
      """
  
      # Populated by recieving the previous party's next_seed (irecv)
      prev_seed = torch.tensor([0], dtype=torch.long)
  
      # Send random seed to next party, receive random seed from prev party
      world_size = ctx.mpc.communicator.get_world_size()
      rank = ctx.mpc.communicator.get_rank()
      if (
          world_size >= 2
      ):  # Guard against segfaults when world_size == 1.
          next_rank = (rank + 1) % world_size
          prev_rank = (next_rank - 2) % world_size
  
          req0 = ctx.mpc.communicator.isend(next_seed, next_rank)
          req1 = ctx.mpc.communicator.irecv(prev_seed, src=prev_rank)
  
          req0.wait()
          req1.wait()
      else:
          prev_seed = next_seed
  
      prev_seed = prev_seed.item()
      next_seed = next_seed.item()
  
      # Broadcast global generator - All parties share one global generator for sync'd rng
      global_seed = ctx.mpc.communicator.broadcast(
          global_seed, 0
      ).item()
  
      # Create one of each seed per party
      # Note: This is configured to coordinate seeds across cuda devices
      # so that we can one party per gpu. If we want to support configurations
      # where each party runs on multiple gpu's across machines, we will
      # need to modify this.
      for device in generators["prev"].keys():
          generators["prev"][device].manual_seed(prev_seed)
          generators["next"][device].manual_seed(next_seed)
          generators["local"][device].manual_seed(local_seed)
          generators["global"][device].manual_seed(global_seed)
  
imports: import builtins
  import copy
  import logging
  import os
  import typing
  import torch
  from .None import nn
  from .None import primitives, provider
  from .communicator import Communicator
  from .config import cfg
  from .cryptensor import CrypTensor
  from .mpc import MPCTensor
  from .ptype import ptype
label_desc: Use image node_id 24 for calling a global function with example usage: _sync_seeds(ctx, generators, next_seed, local_seed, global_seed) without return types