code: def check_no_externals(stage):
      from dvc.utils import format_link
  
      def _is_cached_external(out):
          if out.is_in_repo or not out.use_cache:
              return False
          return True
  
      outs = [
          str(out) for out in stage.outs if _is_cached_external(out)
      ]
      if not outs:
          return
  
      str_outs = ", ".join(outs)
      link = format_link(
          "https://dvc.org/doc/user-guide/pipelines/external-dependencies-and-outputs"
      )
      if stage.is_data_source:
          link = format_link(
              "https://dvc.org/doc/user-guide/data-management/importing-external-data"
          )
      raise StageExternalOutputsError(
          f"Cached output(s) outside of DVC project: {str_outs}. "
          f"See {link} for more info."
      )
  
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 4 for calling a global function with example usage: check_no_externals(stage) and returns: True, False