code: def _safe_compute_error(X, W, H):
      """Frobenius norm between X and WH, safe for sparse array"""
      if not sp.issparse(X):
          error = norm(X - np.dot(W, H))
      else:
          norm_X = np.dot(X.data, X.data)
          norm_WH = trace_dot(np.dot(np.dot(W.T, W), H), H)
          cross_prod = trace_dot((X * H.T), W)
          error = sqrt(norm_X + norm_WH - 2.0 * cross_prod)
      return error
  
imports: from __future__ import division, print_function
  from math import sqrt
  import warnings
  import numbers
  import numpy
  import scipy.sparse
  from ..base import BaseEstimator, TransformerMixin
  from ..utils import check_random_state, check_array
  from ..utils.extmath import randomized_svd, safe_sparse_dot, squared_norm
  from ..utils.extmath import fast_dot
  from ..utils.validation import check_is_fitted, check_non_negative
  from ..utils import deprecated
  from ..exceptions import ConvergenceWarning
  from .cdnmf_fast import _update_cdnmf_fast
label_desc: Use image node_id 6 for calling a global function with example usage: _safe_compute_error(X, W, H) and returns: error