code: def test_estimator_reg(estimator, check):
      if (
          os.environ["PYTEST_CURRENT_TEST"].find(
              "check_supervised_y_no_nan"
          )
          != -1
      ):
          # The test uses float64 and requires the error message to contain:
          #
          #   "value too large for dtype(float64)",
          #
          # while XGBoost stores values as float32.  But XGBoost does verify the label
          # internally, so we replace this test with custom check.
          rng = np.random.RandomState(888)
          X = rng.randn(10, 5)
          y = np.full(10, np.inf)
          with pytest.raises(
              ValueError,
              match="contains NaN, infinity or a value too large",
          ):
              estimator.fit(X, y)
          return
      if (
          os.environ["PYTEST_CURRENT_TEST"].find(
              "check_estimators_overwrite_params"
          )
          != -1
      ):
          # A hack to pass the scikit-learn parameter mutation tests.  XGBoost regressor
          # returns actual internal default values for parameters in `get_params`, but
          # those are set as `None` in sklearn interface to avoid duplication.  So we fit
          # a dummy model and obtain the default parameters here for the mutation tests.
          from sklearn.datasets import make_regression
  
          X, y = make_regression(n_samples=2, n_features=1)
          estimator.set_params(
              **xgb.XGBRegressor().fit(X, y).get_params()
          )
  
      check(estimator)
  
imports: import json
  import os
  import pickle
  import random
  import tempfile
  import warnings
  from typing import Callable, Optional
  import numpy
  import pytest
  from sklearn.utils.estimator_checks import parametrize_with_checks
  import xgboost
  from xgboost import testing
  from xgboost.testing.ranking import run_ranking_categorical, run_ranking_qid_df
  from xgboost.testing.shared import get_feature_weights, validate_data_initialization
  from xgboost.testing.updater import get_basescore
label_desc: Use image node_id 48 for calling a global function with example usage: test_estimator_reg(estimator, check) without return types