code: def _iterate_sparse_X(X):
      """This little hack returns a densified row when iterating over a sparse
      matrix, instead of constructing a sparse matrix for every row that is
      expensive.
      """
      n_samples = X.shape[0]
      X_indices = X.indices
      X_data = X.data
      X_indptr = X.indptr
  
      for i in xrange(n_samples):
          row = np.zeros(X.shape[1])
          startptr, endptr = X_indptr[i], X_indptr[i + 1]
          nonzero_indices = X_indices[startptr:endptr]
          row[nonzero_indices] = X_data[startptr:endptr]
          yield row
  
imports: from __future__ import division
  import warnings
  import numpy
  from scipy import sparse
  from math import sqrt
  from ..metrics.pairwise import euclidean_distances
  from ..base import TransformerMixin, ClusterMixin, BaseEstimator
  from ..externals.six.moves import xrange
  from ..utils import check_array
  from ..utils.extmath import row_norms, safe_sparse_dot
  from ..utils.validation import check_is_fitted
  from ..exceptions import NotFittedError
  from .hierarchical import AgglomerativeClustering
label_desc: Use image node_id 1 for calling a global function with example usage: _iterate_sparse_X(X) without return types