code: def determine_setup(
      inifile: Optional[str],
      args: Sequence[str],
      rootdir_cmd_arg: Optional[str] = None,
      config: Optional["Config"] = None,
  ) -> Tuple[Path, Optional[Path], Dict[str, Union[str, List[str]]]]:
      rootdir = None
      dirs = get_dirs_from_args(args)
      if inifile:
          inipath_ = absolutepath(inifile)
          inipath: Optional[Path] = inipath_
          inicfg = load_config_dict_from_file(inipath_) or {}
          if rootdir_cmd_arg is None:
              rootdir = inipath_.parent
      else:
          ancestor = get_common_ancestor(dirs)
          rootdir, inipath, inicfg = locate_config([ancestor])
          if rootdir is None and rootdir_cmd_arg is None:
              for possible_rootdir in (ancestor, *ancestor.parents):
                  if (possible_rootdir / "setup.py").is_file():
                      rootdir = possible_rootdir
                      break
              else:
                  if dirs != [ancestor]:
                      rootdir, inipath, inicfg = locate_config(dirs)
                  if rootdir is None:
                      if config is not None:
                          cwd = config.invocation_params.dir
                      else:
                          cwd = Path.cwd()
                      rootdir = get_common_ancestor([cwd, ancestor])
                      if is_fs_root(rootdir):
                          rootdir = ancestor
      if rootdir_cmd_arg:
          rootdir = absolutepath(os.path.expandvars(rootdir_cmd_arg))
          if not rootdir.is_dir():
              raise UsageError(
                  "Directory '{}' not found. Check your '--rootdir' option.".format(
                      rootdir
                  )
              )
      assert rootdir is not None
      return rootdir, inipath, inicfg or {}
  
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 6 for calling a global function with example usage: determine_setup(inifile, args, rootdir_cmd_arg, config) and returns: rootdir,  inipath,  unknown