code: def _prep_worktree(
      ds_path,
      pwd,
      globbed,
      assume_ready=None,
      remove_outputs=False,
      rerun_outputs=None,
      jobs=None,
  ):
      """
      Yields
      ------
      dict
        Result records
      """
      # ATTN: For correct path handling, all dataset commands call should be
      # unbound. They should (1) receive a string dataset argument, (2) receive
      # relative paths, and (3) happen within a chpwd(pwd) context.
      with chpwd(pwd):
          for res in prepare_inputs(
              ds_path,
              []
              if assume_ready in ["inputs", "both"]
              else globbed["inputs"],
              # Ignore --assume-ready for extra_inputs. It's an unexposed
              # implementation detail that lets wrappers sneak in inputs.
              extra_inputs=globbed["extra_inputs"],
              jobs=jobs,
          ):
              yield res
  
          if assume_ready not in ["outputs", "both"]:
              if globbed["outputs"]:
                  for res in _install_and_reglob(
                      ds_path, globbed["outputs"]
                  ):
                      yield res
                  for res in _unlock_or_remove(
                      ds_path,
                      globbed["outputs"].expand_strict()
                      if not remove_outputs
                      # when force-removing, exclude declared inputs
                      else set(
                          globbed["outputs"].expand_strict()
                      ).difference(globbed["inputs"].expand_strict()),
                      remove=remove_outputs,
                  ):
                      yield res
  
              if rerun_outputs is not None:
                  for res in _unlock_or_remove(ds_path, rerun_outputs):
                      yield res
  
imports: import json
  import logging
  import os
  import os.path
  import warnings
  from argparse import REMAINDER
  from pathlib import Path
  from tempfile import mkdtemp
  import datalad
  import datalad.support.ansi_colors
  from datalad.config import anything2bool
  from datalad.core.local.save import Save
  from datalad.core.local.status import Status
  from datalad.distribution.dataset import Dataset, EnsureDataset, datasetmethod, require_dataset
  from datalad.distribution.get import Get
  from datalad.distribution.install import Install
  from datalad.interface.base import Interface, build_doc, eval_results
  from datalad.interface.common_opts import jobs_opt, save_message_opt
  from datalad.interface.results import get_status_dict
  from datalad.interface.utils import generic_result_renderer
  from datalad.local.unlock import Unlock
  from datalad.support.constraints import EnsureBool, EnsureChoice, EnsureNone
  from datalad.support.exceptions import CapturedException, CommandError
  from datalad.support.globbedpaths import GlobbedPaths
  from datalad.support.json_py import dump2stream
  from datalad.support.param import Parameter
  from datalad.ui import ui
  from datalad.utils import SequenceFormatter, chpwd, ensure_list, ensure_unicode, get_dataset_root, getpwd, join_cmdline, quote_cmdlinearg
label_desc: Use image node_id 14 for calling a global function with example usage: _prep_worktree(ds_path, pwd, globbed, assume_ready, remove_outputs, rerun_outputs, jobs) without return types