code: def test_beta_divergence(csr_container):
      # Compare _beta_divergence with the reference _beta_divergence_dense
      n_samples = 20
      n_features = 10
      n_components = 5
      beta_losses = [0.0, 0.5, 1.0, 1.5, 2.0, 3.0]
  
      # initialization
      rng = np.random.mtrand.RandomState(42)
      X = rng.randn(n_samples, n_features)
      np.clip(X, 0, None, out=X)
      X_csr = csr_container(X)
      W, H = nmf._initialize_nmf(
          X, n_components, init="random", random_state=42
      )
  
      for beta in beta_losses:
          ref = _beta_divergence_dense(X, W, H, beta)
          loss = nmf._beta_divergence(X, W, H, beta)
          loss_csr = nmf._beta_divergence(X_csr, W, H, beta)
  
          assert_almost_equal(ref, loss, decimal=7)
          assert_almost_equal(ref, loss_csr, decimal=7)
  
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 20 for calling a global function with example usage: test_beta_divergence(csr_container) without return types