code: def execute_function_multithreaded(
      exec_command, args_list, max_workers=100
  ):
      """Execute functions in multithread manner.
  
      Args:
          exec_command: Callable function to run.
          args_list: The arguments list for exec_command, each element will be passed
              into exec_command and run in multithread paralleled.
          max_workers (int, optional): Defaults to 100.
  
      Returns:
          A dictionary that maps index to result of exec_command, i.e. index to the
          result of exec_command taking "index"-th args in the args_list.
      """
      results = {}
      _max_workers = min(max_workers, len(args_list))
      with concurrent.futures.ThreadPoolExecutor(
          max_workers=_max_workers
      ) as executor:
          futures_to_index = {
              executor.submit(exec_command, arg): index
              for index, arg in enumerate(args_list)
          }
          for future in concurrent.futures.as_completed(
              futures_to_index
          ):
              index = futures_to_index[future]
              results[index] = future.result()
      return results
  
file_path: bluefog/bluefog/run/network_util.py
imports: import concurrent.futures
  import io
  import os
  import re
  import socket
  import psutil
  from bluefog.run.horovodrun.common.util import safe_shell_exec
label_desc: Use image node_id 1 for calling a global function with example usage: execute_function_multithreaded(exec_command, args_list, max_workers) and returns: results