code: def _external_only_api(func, alternative=""):
      """Decorator to indicate that a function should not be used internally.
  
      cudf contains many APIs that exist for pandas compatibility but are
      intrinsically inefficient. For some of these cudf has internal
      equivalents that are much faster. Usage of the slow public APIs inside
      our implementation can lead to unnecessary performance bottlenecks.
      Applying this decorator to such functions and setting the environment
      variable NO_EXTERNAL_ONLY_APIS will cause such functions to raise
      exceptions if they are called from anywhere inside cudf, making it easy
      to identify and excise such usage.
  
      The `alternative` should be a complete phrase or sentence since it will
      be used verbatim in error messages.
      """
  
      # If the first arg is a string then an alternative function to use in
      # place of this API was provided, so we pass that to a subsequent call.
      # It would be cleaner to implement this pattern by using a class
      # decorator with a factory method, but there is no way to generically
      # wrap docstrings on a class (we would need the docstring to be on the
      # class itself, not instances, because that's what `help` looks at) and
      # there is also no way to make mypy happy with that approach.
      if isinstance(func, str):
          return lambda actual_func: _external_only_api(
              actual_func, func
          )
  
      if not NO_EXTERNAL_ONLY_APIS:
          return func
  
      @functools.wraps(func)
      def wrapper(*args, **kwargs):
          # Check the immediately preceding frame to see if it's in cudf.
          frame, lineno = next(traceback.walk_stack(None))
          fn = frame.f_code.co_filename
          if _cudf_root in fn and _tests_root not in fn:
              raise RuntimeError(
                  f"External-only API called in {fn} at line {lineno}. "
                  f"{alternative}"
              )
          return func(*args, **kwargs)
  
      return wrapper
  
imports: import decimal
  import functools
  import os
  import traceback
  import warnings
  from typing import FrozenSet, Set, Union
  import numpy
  import pandas
  import rmm
  import cudf
  import cudf.api.types
  from cudf.core import column
  from cudf.core.buffer import as_buffer
label_desc: Use image node_id 2 for calling a global function with example usage: _external_only_api(func, alternative) and returns: wrapper, function, func, func