code: def check_finite(array, force_all_finite=True):
      """Checks that the input is finite if necessary
  
      Parameters
      ----------
      array : object
          Input object to check / convert.
      force_all_finite : boolean or 'allow-nan', (default=True)
          Whether to raise an error on np.inf, np.nan, pd.NA in array. The
          possibilities are:
          - True: Force all values of array to be finite.
          - False: accepts np.inf, np.nan, pd.NA in array.
          - 'allow-nan': accepts only np.nan and pd.NA values in array. Values
            cannot be infinite.
             ``force_all_finite`` accepts the string ``'allow-nan'``.
  
      Returns
      -------
      None or raise error
      """
      if force_all_finite is True:
          if not cp.all(cp.isfinite(array)):
              raise ValueError("Non-finite value encountered in array")
      elif force_all_finite == "allow-nan":
          if cp.any(cp.isinf(array)):
              raise ValueError("Non-finite value encountered in array")
  
file_path: cuml/python/cuml/thirdparty_adapters/adapters.py
imports: from cupyx.scipy import sparse
  from scipy import sparse
  from scipy.sparse import csc_matrix
  from scipy.sparse import csc_matrix
  from cuml.internals.safe_imports import cpu_only_import_from
  from cupyx.scipy.sparse import csc_matrix
  from cuml.internals.safe_imports import gpu_only_import_from
  from cuml.internals.global_settings import GlobalSettings
  from cuml.internals.input_utils import input_to_cupy_array, input_to_host_array
  from cuml.internals.safe_imports import gpu_only_import
  from cuml.internals.safe_imports import cpu_only_import
label_desc: Use image node_id 3 for calling a global function with example usage: check_finite(array, force_all_finite) without return types