code: def get_third_party_modules_from_config(
      config: Dict, role: NodeRole, environ=None
  ):
      environ = environ or os.environ
      third_party_modules = config.get("third_party_modules", [])
      if isinstance(third_party_modules, list):
          modules = third_party_modules
      elif isinstance(third_party_modules, dict):
          key = {
              NodeRole.SUPERVISOR: "supervisor",
              NodeRole.WORKER: "worker",
          }
          modules = third_party_modules.get(key[role], [])
          if not isinstance(modules, list):
              raise TypeError(
                  f"The value type of third_party_modules.{key[role]} "
                  f"should be a list, but got a {type(modules)} instead."
              )
      else:
          raise TypeError(
              f"The value type of third_party_modules should be a list "
              f"or dict, but got a {type(third_party_modules)} instead."
          )
  
      all_modules = []
      for mods in tuple(modules or ()) + (
          environ.get("MARS_LOAD_MODULES"),
      ):
          all_modules.extend(mods.split(",") if mods else [])
      return all_modules
  
file_path: mars/mars/deploy/utils.py
imports: import asyncio
  import os
  import time
  import warnings
  from typing import Callable, Dict, List, Union, TextIO
  import yaml
  from ..services import NodeRole
  from ..utils import merge_dict, flatten_dict_to_nested_dict
label_desc: Use image node_id 5 for calling a global function with example usage: get_third_party_modules_from_config(config, role, environ) and returns: all_modules