code: def test_invalid_metadata():
      # check that passing wrong metadata raises an error
      trs = MetaTransformer(
          transformer=ConsumingTransformer().set_transform_request(
              sample_weight=True
          )
      )
      with pytest.raises(
          TypeError,
          match=(
              re.escape(
                  "transform got unexpected argument(s) {'other_param'}"
              )
          ),
      ):
          trs.fit(X, y).transform(X, other_param=my_weights)
  
      # passing a metadata which is not requested by any estimator should also raise
      trs = MetaTransformer(
          transformer=ConsumingTransformer().set_transform_request(
              sample_weight=False
          )
      )
      with pytest.raises(
          TypeError,
          match=(
              re.escape(
                  "transform got unexpected argument(s) {'sample_weight'}"
              )
          ),
      ):
          trs.fit(X, y).transform(X, 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 12 for calling a global function with example usage: test_invalid_metadata() without return types