code: def _set_random_states(estimator, random_state=None):
      """Sets 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 : numpy.RandomState or int, optional
          Random state used to generate integer values.
  
      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(MAX_RAND_SEED)
  
      if to_set:
          estimator.set_params(**to_set)
  
file_path: catboost/contrib/python/scikit-learn/py2/sklearn/ensemble/base.py
imports: import numpy
  import numbers
  from ..base import clone
  from ..base import BaseEstimator
  from ..base import MetaEstimatorMixin
  from ..utils import _get_n_jobs, check_random_state
label_desc: Use image node_id 1 for calling a global function with example usage: _set_random_states(estimator, random_state) without return types