code: def in_tempdir():
      """Create, return, and change directory to a temporary directory
  
      Examples
      --------
      >>> import os
      >>> my_cwd = os.getcwd()
      >>> with in_tempdir() as tmpdir:
      ...     _ = open('test.txt', 'wt').write('some text')
      ...     assert os.path.isfile('test.txt')
      ...     assert os.path.isfile(os.path.join(tmpdir, 'test.txt'))
      >>> os.path.exists(tmpdir)
      False
      >>> os.getcwd() == my_cwd
      True
      """
      pwd = os.getcwd()
      d = mkdtemp()
      os.chdir(d)
      yield d
      os.chdir(pwd)
      rmtree(d)
  
file_path: catboost/contrib/python/scipy/py2/scipy/_lib/_tmpdirs.py
imports: from __future__ import division, print_function, absolute_import
  import os
  from contextlib import contextmanager
  from shutil import rmtree
  from tempfile import mkdtemp
label_desc: Use image node_id 2 for calling a global function with example usage: in_tempdir() without return types