code: def check_stage_path(repo, path, is_wdir=False):
      from dvc.utils.fs import path_isin
  
      assert repo is not None
  
      error_msg = "{wdir_or_path} '{path}' {{}}".format(
          wdir_or_path="stage working dir" if is_wdir else "file path",
          path=path,
      )
  
      real_path = os.path.abspath(path)
      if not os.path.exists(real_path):
          raise StagePathNotFoundError(
              error_msg.format("does not exist")
          )
  
      if not os.path.isdir(real_path):
          raise StagePathNotDirectoryError(
              error_msg.format("is not directory")
          )
  
      proj_dir = os.path.abspath(repo.root_dir)
      if real_path != proj_dir and not path_isin(real_path, proj_dir):
          raise StagePathOutsideError(
              error_msg.format("is outside of DVC repo")
          )
  
imports: import os
  import pathlib
  from typing import TYPE_CHECKING, Any, Dict, List, Optional, Tuple, Union
  from funcy import concat, first, lsplit, rpartial
  from dvc.annotations import ANNOTATION_FIELDS
  from dvc.exceptions import InvalidArgumentError
  from dvc_data.hashfile.meta import Meta
  from .exceptions import MissingDataSource, StageExternalOutputsError, StagePathNotDirectoryError, StagePathNotFoundError, StagePathOutsideError
label_desc: Use image node_id 1 for calling a global function with example usage: check_stage_path(repo, path, is_wdir) without return types