code: def run_on_leader(pg: dist.ProcessGroup, rank: int):
      def callable(func: Callable[..., T]) -> T:
          @wraps(func)
          def wrapped(*args: Any, **kwargs: Any) -> T:
              return invoke_on_rank_and_broadcast_result(
                  pg, rank, func, *args, **kwargs
              )
  
          return wrapped
  
      return callable
  
imports: from functools import wraps
  from typing import Any, Callable, cast, Optional, TypeVar
  import torch.distributed
label_desc: Use image node_id 3 for calling a global function with example usage: run_on_leader(pg, rank) and returns: callable, wrapped, invoke_on_rank_and_broadcast_result