code: def _assert_all_finite(X):
      """Like assert_all_finite, but only for ndarray."""
      X = np.asanyarray(X)
      # First try an O(n) time, O(1) space solution for the common case that
      # everything is finite; fall back to O(n) space np.isfinite to prevent
      # false positives from overflow in sum method.
      if (
          X.dtype.char in np.typecodes["AllFloat"]
          and not np.isfinite(X.sum())
          and not np.isfinite(X).all()
      ):
          raise ValueError(
              "Input contains NaN, infinity"
              " or a value too large for %r." % X.dtype
          )
  
imports: import warnings
  import numbers
  import numpy
  import scipy.sparse
  from ..externals import six
  from ..utils.fixes import signature
  from .deprecation import deprecated
  from ..exceptions import DataConversionWarning
  from ..exceptions import NonBLASDotWarning
  from ..exceptions import NotFittedError
label_desc: Use image node_id 1 for calling a global function with example usage: _assert_all_finite(X) without return types