code: def add(
      repo: "Repo",
      targets: Union["StrOrBytesPath", Iterator["StrOrBytesPath"]],
      no_commit: bool = False,
      glob: bool = False,
      out: Optional[str] = None,
      remote: Optional[str] = None,
      to_remote: bool = False,
      remote_jobs: Optional[int] = None,
      force: bool = False,
  ) -> List["Stage"]:
      add_targets = find_targets(targets, glob=glob)
      if not add_targets:
          return []
  
      stages_with_targets = {
          target: get_or_create_stage(
              repo,
              target,
              out=out,
              to_remote=to_remote,
              force=force,
          )
          for target in add_targets
      }
  
      stages = [stage for stage, _ in stages_with_targets.values()]
      msg = "Collecting stages from the workspace"
      with translate_graph_error(stages), ui.status(msg) as st:
          repo.check_graph(
              stages=stages,
              callback=lambda: st.update("Checking graph"),
          )
  
      if to_remote or out:
          assert (
              len(stages_with_targets) == 1
          ), "multiple targets are unsupported"
          (source, (stage, _)) = next(iter(stages_with_targets.items()))
          _add_transfer(
              stage,
              source,
              remote,
              to_remote,
              jobs=remote_jobs,
              force=force,
          )
          return [stage]
  
      with warn_link_failures() as link_failures:
          for source, (stage, output_exists) in progress_iter(
              stages_with_targets
          ):
              try:
                  _add(
                      stage,
                      source if output_exists else None,
                      no_commit=no_commit,
                  )
              except CacheLinkError:
                  link_failures.append(stage.relpath)
      return stages
  
file_path: dvc/dvc/repo/add.py
imports: import os
  from contextlib import contextmanager
  from typing import TYPE_CHECKING, Dict, Iterator, List, NamedTuple, Optional, Tuple, Union
  from dvc.exceptions import CacheLinkError, DvcException, OutputDuplicationError, OutputNotFoundError, OverlappingOutputPathsError
  from dvc.repo.scm_context import scm_context
  from dvc.ui import ui
  from dvc.utils import glob_targets, resolve_output, resolve_paths
  from .None import locked
label_desc: Use image node_id 8 for calling a global function with example usage: add(repo, targets, no_commit, glob, out, remote, to_remote, remote_jobs, force) and returns: stages, list, list