code: def schedule_remote_fn_on_all_nodes(
      remote_fn, exclude_head: bool = False, *args, **kwargs
  ):
      head_ip = ray.util.get_node_ip_address()
  
      futures = []
      for node in ray.nodes():
          if not node["Alive"]:
              continue
  
          node_ip = node["NodeManagerAddress"]
  
          if exclude_head and node_ip == head_ip:
              continue
  
          node_id = node["NodeID"]
  
          future = _force_on_node(node_id, remote_fn).remote(
              *args,
              **kwargs,
          )
          futures.append(future)
      return futures
  
imports: import os
  import socket
  import subprocess
  from collections import defaultdict
  from contextlib import closing
  from pathlib import Path
  from ray.air.util.node import _force_on_node
  import ray
  from typing import Any, List, Dict, Union, Callable
label_desc: Use image node_id 1 for calling a global function with example usage: schedule_remote_fn_on_all_nodes(remote_fn, exclude_head) and returns: futures