code: def test_simple_metadata_routing():
      # Tests that metadata is properly routed
  
      # The underlying estimator doesn't accept or request metadata
      clf = WeightedMetaClassifier(estimator=NonConsumingClassifier())
      clf.fit(X, y)
  
      # Meta-estimator consumes sample_weight, but doesn't forward it to the underlying
      # estimator
      clf = WeightedMetaClassifier(estimator=NonConsumingClassifier())
      clf.fit(X, y, sample_weight=my_weights)
  
      # If the estimator accepts the metadata but doesn't explicitly say it doesn't
      # need it, there's an error
      clf = WeightedMetaClassifier(estimator=ConsumingClassifier())
      err_message = (
          "[sample_weight] are passed but are not explicitly set as requested or"
          " not for ConsumingClassifier.fit"
      )
      with pytest.raises(ValueError, match=re.escape(err_message)):
          clf.fit(X, y, sample_weight=my_weights)
  
      # Explicitly saying the estimator doesn't need it, makes the error go away,
      # because in this case `WeightedMetaClassifier` consumes `sample_weight`. If
      # there was no consumer of sample_weight, passing it would result in an
      # error.
      clf = WeightedMetaClassifier(
          estimator=ConsumingClassifier().set_fit_request(
              sample_weight=False
          )
      )
      # this doesn't raise since WeightedMetaClassifier itself is a consumer,
      # and passing metadata to the consumer directly is fine regardless of its
      # metadata_request values.
      clf.fit(X, y, sample_weight=my_weights)
      check_recorded_metadata(clf.estimator_, "fit")
  
      # Requesting a metadata will make the meta-estimator forward it correctly
      clf = WeightedMetaClassifier(
          estimator=ConsumingClassifier().set_fit_request(
              sample_weight=True
          )
      )
      clf.fit(X, y, sample_weight=my_weights)
      check_recorded_metadata(
          clf.estimator_, "fit", sample_weight=my_weights
      )
  
      # And requesting it with an alias
      clf = WeightedMetaClassifier(
          estimator=ConsumingClassifier().set_fit_request(
              sample_weight="alternative_weight"
          )
      )
      clf.fit(X, y, alternative_weight=my_weights)
      check_recorded_metadata(
          clf.estimator_, "fit", sample_weight=my_weights
      )
  
imports: import re
  import numpy
  import pytest
  from sklearn import config_context
  from sklearn.base import BaseEstimator, clone
  from sklearn.linear_model import LinearRegression
  from sklearn.tests.metadata_routing_common import ConsumingClassifier, ConsumingRegressor, ConsumingTransformer, MetaRegressor, MetaTransformer, NonConsumingClassifier, WeightedMetaClassifier, WeightedMetaRegressor, _Registry, assert_request_equal, assert_request_is_empty, check_recorded_metadata
  from sklearn.utils import metadata_routing
  from sklearn.utils._metadata_requests import COMPOSITE_METHODS, METHODS, SIMPLE_METHODS, MethodMetadataRequest, MethodPair, _MetadataRequester, request_is_alias, request_is_valid
  from sklearn.utils.metadata_routing import MetadataRequest, MetadataRouter, MethodMapping, get_routing_for_object, process_routing
  from sklearn.utils.validation import check_is_fitted
label_desc: Use image node_id 9 for calling a global function with example usage: test_simple_metadata_routing() without return types