code: def _simulate_sha(n, r, eta, max_iter=None):
      """
      Parameters
      ----------
      n : int
          Number of initial models
      r : int
          Number of initial calls
      eta : int
          aggressiveness of the search
  
      Returns
      -------
      meta : {"total_calls": int, "max_iter": int}
  
      Notes
      -----
      n, r and eta come from Hyperband
      """
      calls = {k: 0 for k in range(n)}
      for k in itertools.count():
          n_i = int(math.floor(n * eta**-k))
          r_i = np.round(r * eta**k).astype(int)
          for k in range(n_i):
              calls[k] = r_i
          if n_i <= 1 or (max_iter and r_i >= max_iter):
              break
      return {
          "total_calls": sum(calls.values()),
          "max_iter": max(calls.values()),
      }
  
file_path: dask-ml/dask_ml/model_selection/_successive_halving.py
imports: import itertools
  import math
  import numpy
  import toolz
  from sklearn.utils.validation import check_is_fitted
  from ._incremental import IncrementalSearchCV
label_desc: Use image node_id 1 for calling a global function with example usage: _simulate_sha(n, r, eta, max_iter) and returns: dict