code: def _set_random_states(estimator, random_state=None):
      """Set fixed random_state parameters for an estimator.
  
      Finds all parameters ending ``random_state`` and sets them to integers
      derived from ``random_state``.
  
      Parameters
      ----------
      estimator : estimator supporting get/set_params
          Estimator with potential randomness managed by random_state
          parameters.
  
      random_state : int, RandomState instance or None, default=None
          Pseudo-random number generator to control the generation of the random
          integers. Pass an int for reproducible output across multiple function
          calls.
          See :term:`Glossary <random_state>`.
  
      Notes
      -----
      This does not necessarily set *all* ``random_state`` attributes that
      control an estimator's randomness, only those accessible through
      ``estimator.get_params()``.  ``random_state``s not controlled include
      those belonging to:
  
          * cross-validation splitters
          * ``scipy.stats`` rvs
      """
      random_state = check_random_state(random_state)
      to_set = {}
      for key in sorted(estimator.get_params(deep=True)):
          if key == "random_state" or key.endswith("__random_state"):
              to_set[key] = random_state.randint(np.iinfo(np.int32).max)
  
      if to_set:
          estimator.set_params(**to_set)
  
imports: from abc import ABCMeta, abstractmethod
  from typing import List
  import numpy
  from joblib import effective_n_jobs
  from ..base import BaseEstimator, MetaEstimatorMixin, clone, is_classifier, is_regressor
  from ..utils import Bunch, _print_elapsed_time, check_random_state
  from ..utils._tags import _safe_tags
  from ..utils.metaestimators import _BaseComposition
label_desc: Use image node_id 2 for calling a global function with example usage: _set_random_states(estimator, random_state) without return types