code: def test_logistic_regression(
      num_classes,
      dtype,
      penalty,
      l1_ratio,
      fit_intercept,
      nrows,
      column_info,
      C,
      tol,
  ):
      ncols, n_info = column_info
      # Checking sklearn >= 0.21 for testing elasticnet
      sk_check = LooseVersion(str(sklearn.__version__)) >= LooseVersion(
          "0.21.0"
      )
      if not sk_check and penalty == "elasticnet":
          pytest.skip(
              "Need sklearn > 0.21 for testing logistic with"
              "elastic net."
          )
  
      X_train, X_test, y_train, y_test = make_classification_dataset(
          datatype=dtype,
          nrows=nrows,
          ncols=ncols,
          n_info=n_info,
          num_classes=num_classes,
      )
      y_train = y_train.astype(dtype)
      y_test = y_test.astype(dtype)
  
      culog = cuLog(
          penalty=penalty,
          l1_ratio=l1_ratio,
          C=C,
          fit_intercept=fit_intercept,
          tol=tol,
      )
      culog.fit(X_train, y_train)
  
      # Only solver=saga supports elasticnet in scikit
      if penalty in ["elasticnet", "l1"]:
          if sk_check:
              sklog = skLog(
                  penalty=penalty,
                  l1_ratio=l1_ratio,
                  solver="saga",
                  C=C,
                  fit_intercept=fit_intercept,
                  multi_class="auto",
              )
          else:
              sklog = skLog(
                  penalty=penalty,
                  solver="saga",
                  C=C,
                  fit_intercept=fit_intercept,
                  multi_class="auto",
              )
      else:
          sklog = skLog(
              penalty=penalty,
              solver="lbfgs",
              C=C,
              fit_intercept=fit_intercept,
              multi_class="auto",
          )
  
      sklog.fit(X_train, y_train)
  
      # Setting tolerance to lowest possible per loss to detect regressions
      # as much as possible
      cu_preds = culog.predict(X_test)
      tol_test = 0.012
      tol_train = 0.006
      if num_classes == 10 and penalty in ["elasticnet", "l1"]:
          tol_test *= 10
          tol_train *= 10
  
      assert (
          culog.score(X_train, y_train)
          >= sklog.score(X_train, y_train) - tol_train
      )
      assert (
          culog.score(X_test, y_test)
          >= sklog.score(X_test, y_test) - tol_test
      )
      assert len(np.unique(cu_preds)) == len(np.unique(y_test))
  
      if fit_intercept is False:
          assert np.array_equal(culog.intercept_, sklog.intercept_)
  
imports: from contextlib import nullcontext
  from distutils.version import LooseVersion
  from functools import lru_cache
  import pytest
  import sklearn
  from cuml.internals.array import elements_in_representable_range
  from cuml.internals.safe_imports import cpu_only_import, cpu_only_import_from, gpu_only_import
  from cuml.testing.strategies import regression_datasets, split_datasets, standard_classification_datasets, standard_regression_datasets
  from cuml.testing.utils import array_difference, array_equal, quality_param, small_classification_dataset, small_regression_dataset, stress_param, unit_param
  from hypothesis import assume, example, given, note
  from hypothesis import strategies
  from hypothesis import target
  from hypothesis.extra.numpy import floating_dtypes
  from sklearn.datasets import load_breast_cancer, load_digits, make_classification, make_regression
  from sklearn.linear_model import LinearRegression
  from sklearn.linear_model import LogisticRegression
  from sklearn.linear_model import Ridge
  from sklearn.model_selection import train_test_split
  from cuml import ElasticNet
  from cuml import LinearRegression
  from cuml import LogisticRegression
  from cuml import Ridge
label_desc: Use image node_id 15 for calling a global function with example usage: test_logistic_regression(num_classes, dtype, penalty, l1_ratio, fit_intercept, nrows, column_info, C, tol) without return types