code: def _get_modification_order(
      settings: Settings,
  ) -> Tuple[Tuple[str, ...], Tuple[str, ...]]:
      """Return the order in which settings should be modified, based on dependencies."""
      dependency_graph = Graph()
  
      props = tuple(get_type_hints(Settings).keys())
  
      # discover prop dependencies from validator methods and runtime hooks
  
      prefix = "_validate_"
      symbols = set(dir(settings))
      validator_methods = tuple(
          sorted(m for m in symbols if m.startswith(prefix))
      )
  
      # extract dependencies from validator methods
      for m in validator_methods:
          setting = m.split(prefix)[1]
          dependency_graph.add_node(setting)
          # if the method is not static, inspect its code to find the attributes it depends on
          if (
              not isinstance(Settings.__dict__[m], staticmethod)
              and not isinstance(Settings.__dict__[m], classmethod)
              and Settings.__dict__[m].__code__.co_argcount > 0
          ):
              unbound_closure_vars = inspect.getclosurevars(
                  Settings.__dict__[m]
              ).unbound
              dependencies = (
                  v for v in unbound_closure_vars if v in props
              )
              for d in dependencies:
                  dependency_graph.add_node(d)
                  dependency_graph.add_edge(setting, d)
  
      # extract dependencies from props' runtime hooks
      default_props = settings._default_props()
      for prop, spec in default_props.items():
          if "hook" not in spec:
              continue
  
          dependency_graph.add_node(prop)
  
          hook = spec["hook"]
          if callable(hook):
              hook = [hook]
  
          for h in hook:
              unbound_closure_vars = inspect.getclosurevars(h).unbound
              dependencies = (
                  v for v in unbound_closure_vars if v in props
              )
              for d in dependencies:
                  dependency_graph.add_node(d)
                  dependency_graph.add_edge(prop, d)
  
      modification_order = dependency_graph.topological_sort_dfs()
      return props, tuple(modification_order)
  
file_path: wandb/wandb/sdk/lib/_settings_toposort_generate.py
imports: import inspect
  import sys
  from typing import Dict, List, Set, Tuple
  from wandb.errors import UsageError
  from wandb.sdk.wandb_settings import Settings
label_desc: Use image node_id 1 for calling a global function with example usage: _get_modification_order(settings) and returns: props,  tuple