code: def _beta_divergence_dense(X, W, H, beta):
      """Compute the beta-divergence of X and W.H for dense array only.
  
      Used as a reference for testing nmf._beta_divergence.
      """
      WH = np.dot(W, H)
  
      if beta == 2:
          return squared_norm(X - WH) / 2
  
      WH_Xnonzero = WH[X != 0]
      X_nonzero = X[X != 0]
      np.maximum(WH_Xnonzero, 1e-9, out=WH_Xnonzero)
  
      if beta == 1:
          res = np.sum(X_nonzero * np.log(X_nonzero / WH_Xnonzero))
          res += WH.sum() - X.sum()
  
      elif beta == 0:
          div = X_nonzero / WH_Xnonzero
          res = np.sum(div) - X.size - np.sum(np.log(div))
      else:
          res = (X_nonzero**beta).sum()
          res += (beta - 1) * (WH**beta).sum()
          res -= beta * (X_nonzero * (WH_Xnonzero ** (beta - 1))).sum()
          res /= beta * (beta - 1)
  
      return res
  
imports: import re
  import sys
  import warnings
  from io import StringIO
  import numpy
  import pytest
  from scipy import linalg
  from sklearn.base import clone
  from sklearn.decomposition import NMF, MiniBatchNMF, non_negative_factorization
  from sklearn.decomposition import _nmf
  from sklearn.exceptions import ConvergenceWarning
  from sklearn.utils._testing import assert_allclose, assert_almost_equal, assert_array_almost_equal, assert_array_equal, ignore_warnings
  from sklearn.utils.extmath import squared_norm
  from sklearn.utils.fixes import CSC_CONTAINERS, CSR_CONTAINERS
label_desc: Use image node_id 19 for calling a global function with example usage: _beta_divergence_dense(X, W, H, beta) and returns: res, unknown