code: def test_fit_transform_not_associated_with_y_if_ordinal_categorical_is_not(
      global_random_seed,
  ):
      cardinality = (
          30  # not too large, otherwise we need a very large n_samples
      )
      n_samples = 3000
      rng = np.random.RandomState(global_random_seed)
      y_train = rng.normal(size=n_samples)
      X_train = rng.randint(0, cardinality, size=n_samples).reshape(
          -1, 1
      )
  
      # Sort by y_train to attempt to cause a leak
      y_sorted_indices = y_train.argsort()
      y_train = y_train[y_sorted_indices]
      X_train = X_train[y_sorted_indices]
  
      target_encoder = TargetEncoder(
          shuffle=True, random_state=global_random_seed
      )
      X_encoded_train_shuffled = target_encoder.fit_transform(
          X_train, y_train
      )
  
      target_encoder = TargetEncoder(shuffle=False)
      X_encoded_train_no_shuffled = target_encoder.fit_transform(
          X_train, y_train
      )
  
      # Check that no information about y_train has leaked into X_train:
      regressor = RandomForestRegressor(
          n_estimators=10,
          min_samples_leaf=20,
          random_state=global_random_seed,
      )
  
      # It's impossible to learn a good predictive model on the training set when
      # using the original representation X_train or the target encoded
      # representation with shuffled inner CV. For the latter, no information
      # about y_train has inadvertently leaked into the prior used to generate
      # `X_encoded_train_shuffled`:
      cv = ShuffleSplit(n_splits=50, random_state=global_random_seed)
      assert (
          cross_val_score(regressor, X_train, y_train, cv=cv).mean()
          < 0.1
      )
      assert (
          cross_val_score(
              regressor, X_encoded_train_shuffled, y_train, cv=cv
          ).mean()
          < 0.1
      )
  
      # Without the inner CV shuffling, a lot of information about y_train goes into the
      # the per-fold y_train.mean() priors: shrinkage is no longer effective in this
      # case and would no longer be able to prevent downstream over-fitting.
      assert (
          cross_val_score(
              regressor, X_encoded_train_no_shuffled, y_train, cv=cv
          ).mean()
          > 0.5
      )
  
imports: import re
  import numpy
  import pytest
  from numpy.testing import assert_allclose, assert_array_equal
  from sklearn.ensemble import RandomForestRegressor
  from sklearn.linear_model import Ridge
  from sklearn.model_selection import KFold, ShuffleSplit, StratifiedKFold, cross_val_score, train_test_split
  from sklearn.pipeline import make_pipeline
  from sklearn.preprocessing import KBinsDiscretizer, LabelBinarizer, LabelEncoder, TargetEncoder
label_desc: Use image node_id 10 for calling a global function with example usage: test_fit_transform_not_associated_with_y_if_ordinal_categorical_is_not(global_random_seed) without return types