code: def copy_to_tmp(source):
      
      tmp_dir = tempfile.mkdtemp()
      # Use pathlib because os.path.basename is different depending on whether
      # the path ends in a /
      p = pathlib.Path(source)
      dirname = p.name or 'temp'
      new_dir = os.path.join(tmp_dir, dirname)
      if os.path.isdir(source):
          shutil.copytree(source, new_dir)
      else:
          shutil.copy2(source, new_dir)
      return new_dir
docs: Copies ``source`` to a temporary directory, and returns the copied
      location.
  
      If source is a file, the copied location is also a file.