code: def test_mnnb(kind, global_random_seed, csr_container):
      # Test Multinomial Naive Bayes classification.
      # This checks that MultinomialNB implements fit and predict and returns
      # correct values for a simple toy dataset.
      X2, y2 = get_random_integer_x_three_classes_y(global_random_seed)
  
      if kind == "dense":
          X = X2
      elif kind == "sparse":
          X = csr_container(X2)
  
      # Check the ability to predict the learning set.
      clf = MultinomialNB()
  
      msg = "Negative values in data passed to"
      with pytest.raises(ValueError, match=msg):
          clf.fit(-X, y2)
      y_pred = clf.fit(X, y2).predict(X)
  
      assert_array_equal(y_pred, y2)
  
      # Verify that np.log(clf.predict_proba(X)) gives the same results as
      # clf.predict_log_proba(X)
      y_pred_proba = clf.predict_proba(X)
      y_pred_log_proba = clf.predict_log_proba(X)
      assert_array_almost_equal(
          np.log(y_pred_proba), y_pred_log_proba, 8
      )
  
      # Check that incremental fitting yields the same results
      clf2 = MultinomialNB()
      clf2.partial_fit(X[:2], y2[:2], classes=np.unique(y2))
      clf2.partial_fit(X[2:5], y2[2:5])
      clf2.partial_fit(X[5:], y2[5:])
  
      y_pred2 = clf2.predict(X)
      assert_array_equal(y_pred2, y2)
  
      y_pred_proba2 = clf2.predict_proba(X)
      y_pred_log_proba2 = clf2.predict_log_proba(X)
      assert_array_almost_equal(
          np.log(y_pred_proba2), y_pred_log_proba2, 8
      )
      assert_array_almost_equal(y_pred_proba2, y_pred_proba)
      assert_array_almost_equal(y_pred_log_proba2, y_pred_log_proba)
  
      # Partial fit on the whole data at once should be the same as fit too
      clf3 = MultinomialNB()
      clf3.partial_fit(X, y2, classes=np.unique(y2))
  
      y_pred3 = clf3.predict(X)
      assert_array_equal(y_pred3, y2)
      y_pred_proba3 = clf3.predict_proba(X)
      y_pred_log_proba3 = clf3.predict_log_proba(X)
      assert_array_almost_equal(
          np.log(y_pred_proba3), y_pred_log_proba3, 8
      )
      assert_array_almost_equal(y_pred_proba3, y_pred_proba)
      assert_array_almost_equal(y_pred_log_proba3, y_pred_log_proba)
  
imports: import re
  import warnings
  import numpy
  import pytest
  from scipy.special import logsumexp
  from sklearn.datasets import load_digits, load_iris
  from sklearn.model_selection import cross_val_score, train_test_split
  from sklearn.naive_bayes import BernoulliNB, CategoricalNB, ComplementNB, GaussianNB, MultinomialNB
  from sklearn.utils._testing import assert_allclose, assert_almost_equal, assert_array_almost_equal, assert_array_equal
  from sklearn.utils.fixes import CSR_CONTAINERS
label_desc: Use image node_id 24 for calling a global function with example usage: test_mnnb(kind, global_random_seed, csr_container) without return types