code: def expand_environment_variables(config: Any) -> Any:
      """Expand environment variables in a nested config dictionary
  
      This function will recursively search through any nested dictionaries
      and/or lists.
  
      Parameters
      ----------
      config : dict, iterable, or str
          Input object to search for environment variables
  
      Returns
      -------
      config : same type as input
  
      Examples
      --------
      >>> expand_environment_variables({'x': [1, 2, '$USER']})  # doctest: +SKIP
      {'x': [1, 2, 'my-username']}
      """
      if isinstance(config, Mapping):
          return {
              k: expand_environment_variables(v)
              for k, v in config.items()
          }
      elif isinstance(config, str):
          return os.path.expandvars(config)
      elif isinstance(config, (list, tuple, builtins.set)):
          return type(config)(
              expand_environment_variables(v) for v in config
          )
      else:
          return config
  
imports: from __future__ import annotations
  import ast
  import base64
  import builtins
  import json
  import os
  import site
  import sys
  import threading
  import warnings
  from collections.abc import Mapping, Sequence
  from typing import Any, Literal
  import yaml
  from dask.typing import no_default
label_desc: Use image node_id 14 for calling a global function with example usage: expand_environment_variables(config) and returns: unknown, os, type, config