code: def _get_patience(patience, max_iter, aggressiveness, tol):
      if not isinstance(patience, bool) and patience < max(
          max_iter // aggressiveness, 1
      ):
          msg = (
              "The goal of `patience` is to stop training estimators that have "
              "already converged *when few estimators remain*. "
              "Hyperband is already an (almost optimal) adaptive scheme, "
              "and patience should be large to be a minimal layer on top "
              "of Hyperband. \n\n"
              "To clear this warning, set \n\n"
              "    * patience=True\n"
              "    * patience >= {}\n"
              "    * tol=None or tol=np.nan\n\n"
              "instead of patience={} "
          )
          if (tol is not None) and not np.isnan(tol):
              warn(msg.format(max_iter // aggressiveness, patience))
      elif isinstance(patience, bool) and patience:
          return max(max_iter // aggressiveness, 1)
      elif isinstance(patience, bool) and not patience:
          return False
      return int(patience)
  
file_path: dask-ml/dask_ml/model_selection/_hyperband.py
imports: from __future__ import division
  import asyncio
  import logging
  import math
  from typing import Any, Callable, Dict, Iterable, List, Tuple, Union
  from warnings import warn
  import numpy
  from sklearn.utils import check_random_state
  from ._incremental import BaseIncrementalSearchCV
  from ._successive_halving import SuccessiveHalvingSearchCV
label_desc: Use image node_id 5 for calling a global function with example usage: _get_patience(patience, max_iter, aggressiveness, tol) and returns: int, max, False