code: def wrap_cython_function(func, restype, arg_types):
      impls = _available_impls(func)
      compatible = []
      for sig, capsule in impls:
          if sig.provides(restype, arg_types):
              compatible.append((sig, capsule))
  
      def sort_key(args):
          sig, _ = args
  
          # Prefer functions with less inputs bytes
          argsize = sum(
              np.dtype(dtype).itemsize for dtype in sig.arg_dtypes
          )
  
          # Prefer functions with more exact (integer) arguments
          num_inexact = sum(
              np.issubdtype(dtype, np.inexact)
              for dtype in sig.arg_dtypes
          )
          return (num_inexact, argsize)
  
      compatible.sort(key=sort_key)
  
      if not compatible:
          raise NotImplementedError(
              f"Could not find a compatible impl of {func}"
          )
      sig, capsule = compatible[0]
      return _CythonWrapper(func, sig, capsule)
  
imports: import ctypes
  import importlib
  import re
  from collections.abc import Mapping
  from dataclasses import dataclass
  from typing import Any, Callable, Optional, cast
  import numba
  import numpy
  from numpy.typing import DTypeLike
  from scipy import LowLevelCallable
label_desc: Use image node_id 2 for calling a global function with example usage: wrap_cython_function(func, restype, arg_types) and returns: _CythonWrapper, num_inexact,  argsize