code: def test_nmf_negative_beta_loss(csr_container):
      # Test that an error is raised if beta_loss < 0 and X contains zeros.
      # Test that the output has not NaN values when the input contains zeros.
      n_samples = 6
      n_features = 5
      n_components = 3
  
      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)
  
      def _assert_nmf_no_nan(X, beta_loss):
          W, H, _ = non_negative_factorization(
              X,
              init="random",
              n_components=n_components,
              solver="mu",
              beta_loss=beta_loss,
              random_state=0,
              max_iter=1000,
          )
          assert not np.any(np.isnan(W))
          assert not np.any(np.isnan(H))
  
      msg = "When beta_loss <= 0 and X contains zeros, the solver may diverge."
      for beta_loss in (-0.6, 0.0):
          with pytest.raises(ValueError, match=msg):
              _assert_nmf_no_nan(X, beta_loss)
          _assert_nmf_no_nan(X + 1e-9, beta_loss)
  
      for beta_loss in (0.2, 1.0, 1.2, 2.0, 2.5):
          _assert_nmf_no_nan(X, beta_loss)
          _assert_nmf_no_nan(X_csr, beta_loss)
  
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 23 for calling a global function with example usage: test_nmf_negative_beta_loss(csr_container) without return types