code: def locate_config(
      args: Iterable[Path],
  ) -> Tuple[
      Optional[Path], Optional[Path], Dict[str, Union[str, List[str]]]
  ]:
      """Search in the list of arguments for a valid ini-file for pytest,
      and return a tuple of (rootdir, inifile, cfg-dict)."""
      config_names = [
          "pytest.ini",
          ".pytest.ini",
          "pyproject.toml",
          "tox.ini",
          "setup.cfg",
      ]
      args = [x for x in args if not str(x).startswith("-")]
      if not args:
          args = [Path.cwd()]
      for arg in args:
          argpath = absolutepath(arg)
          for base in (argpath, *argpath.parents):
              for config_name in config_names:
                  p = base / config_name
                  if p.is_file():
                      ini_config = load_config_dict_from_file(p)
                      if ini_config is not None:
                          return base, p, ini_config
      return None, None, {}
  
imports: import os
  import sys
  from pathlib import Path
  from typing import Dict
  from typing import Iterable
  from typing import List
  from typing import Optional
  from typing import Sequence
  from typing import Tuple
  from typing import TYPE_CHECKING
  from typing import Union
  import iniconfig
  from .exceptions import UsageError
  from _pytest.outcomes import fail
  from _pytest.pathlib import absolutepath
  from _pytest.pathlib import commonpath
  from _pytest.pathlib import safe_exists
label_desc: Use image node_id 3 for calling a global function with example usage: locate_config(args) and returns: None,  None,  dict, base,  p,  ini_config