code: def cd(
      path: Union[str, pathlib.Path]
  ) -> Iterator[str]:  # pylint: disable=C0103
      """
      Temporarily change working directory.
      TODO(hcho3): Remove this once we adopt Python 3.11, which implements contextlib.chdir.
      """
      path = str(path)
      path = os.path.realpath(path)
      cwd = os.getcwd()
      os.chdir(path)
      try:
          yield path
      finally:
          os.chdir(cwd)
  
file_path: xgboost/python-package/packager/pep517.py
imports: import dataclasses
  import logging
  import os
  import pathlib
  import tempfile
  from contextlib import contextmanager
  from typing import Any, Dict, Iterator, Optional, Union
  import hatchling.build
  from .build_config import BuildConfiguration
  from .nativelib import locate_local_libxgboost, locate_or_build_libxgboost
  from .sdist import copy_cpp_src_tree
  from .util import copy_with_logging, copytree_with_logging
label_desc: Use image node_id 1 for calling a global function with example usage: cd(path) without return types