code: def test_nmf_multiplicative_update_sparse(csr_container):
      # Compare sparse and dense input in multiplicative update NMF
      # Also test continuity of the results with respect to beta_loss parameter
      n_samples = 20
      n_features = 10
      n_components = 5
      alpha = 0.1
      l1_ratio = 0.5
      n_iter = 20
  
      # initialization
      rng = np.random.mtrand.RandomState(1337)
      X = rng.randn(n_samples, n_features)
      X = np.abs(X)
      X_csr = csr_container(X)
      W0, H0 = nmf._initialize_nmf(
          X, n_components, init="random", random_state=42
      )
  
      for beta_loss in (-1.2, 0, 0.2, 1.0, 2.0, 2.5):
          # Reference with dense array X
          W, H = W0.copy(), H0.copy()
          W1, H1, _ = non_negative_factorization(
              X,
              W,
              H,
              n_components,
              init="custom",
              update_H=True,
              solver="mu",
              beta_loss=beta_loss,
              max_iter=n_iter,
              alpha_W=alpha,
              l1_ratio=l1_ratio,
              random_state=42,
          )
  
          # Compare with sparse X
          W, H = W0.copy(), H0.copy()
          W2, H2, _ = non_negative_factorization(
              X_csr,
              W,
              H,
              n_components,
              init="custom",
              update_H=True,
              solver="mu",
              beta_loss=beta_loss,
              max_iter=n_iter,
              alpha_W=alpha,
              l1_ratio=l1_ratio,
              random_state=42,
          )
  
          assert_allclose(W1, W2, atol=1e-7)
          assert_allclose(H1, H2, atol=1e-7)
  
          # Compare with almost same beta_loss, since some values have a specific
          # behavior, but the results should be continuous w.r.t beta_loss
          beta_loss -= 1.0e-5
          W, H = W0.copy(), H0.copy()
          W3, H3, _ = non_negative_factorization(
              X_csr,
              W,
              H,
              n_components,
              init="custom",
              update_H=True,
              solver="mu",
              beta_loss=beta_loss,
              max_iter=n_iter,
              alpha_W=alpha,
              l1_ratio=l1_ratio,
              random_state=42,
          )
  
          assert_allclose(W1, W3, atol=1e-4)
          assert_allclose(H1, H3, atol=1e-4)
  
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 22 for calling a global function with example usage: test_nmf_multiplicative_update_sparse(csr_container) without return types