code: def get_finite_row_indices(matrix):
      """Returns the indices of the purely finite rows of a sparse matrix or dense ndarray"""
      if issparse(matrix):
          row_indices = np.array(
              [
                  i
                  for i, row in enumerate(matrix.tolil().data)
                  if np.all(np.isfinite(row))
              ]
          )
      else:
          row_indices = np.where(
              np.isfinite(matrix).sum(axis=1) == matrix.shape[1]
          )[0]
      return row_indices
  
imports: import numpy
  from sklearn.base import BaseEstimator, ClusterMixin
  from sklearn.metrics import pairwise_distances
  from scipy.sparse import issparse
  from sklearn.neighbors import KDTree, BallTree
  from joblib import Memory
  from warnings import warn
  from sklearn.utils import check_array
  from joblib.parallel import cpu_count
  from scipy.sparse import csgraph
  from ._hdbscan_linkage import single_linkage, mst_linkage_core, mst_linkage_core_vector, label
  from ._hdbscan_tree import condense_tree, compute_stability, get_clusters, outlier_scores
  from ._hdbscan_reachability import mutual_reachability, sparse_mutual_reachability
  from ._hdbscan_boruvka import KDTreeBoruvkaAlgorithm, BallTreeBoruvkaAlgorithm
  from .dist_metrics import DistanceMetric
  from .plots import CondensedTree, SingleLinkageTree, MinimumSpanningTree
  from .prediction import PredictionData
  from numpy import isclose
label_desc: Use image node_id 12 for calling a global function with example usage: get_finite_row_indices(matrix) and returns: row_indices