code: def assert_all_finite(X, allow_nan=False):
      """Throw a ValueError if X contains NaN or infinity.
  
      Parameters
      ----------
      X : array or sparse matrix
      allow_nan : bool
      """
      _assert_all_finite(X.data if sp.issparse(X) else X, allow_nan)
  
imports: from collections.abc import Sequence
  from itertools import chain
  from scipy.sparse import issparse
  from scipy.sparse.base import spmatrix
  from scipy.sparse import dok_matrix
  from scipy.sparse import lil_matrix
  import scipy.sparse
  import numpy
  import pandas
label_desc: Use image node_id 2 for calling a global function with example usage: assert_all_finite(X, allow_nan) without return types