class_docstr: Tuner is the recommended way of launching hyperparameter tuning jobs with Ray Tune.
  
  Args:
      trainable: The trainable to be tuned.
      param_space: Search space of the tuning job.
          One thing to note is that both preprocessor and dataset can be tuned here.
      tune_config: Tuning algorithm specific configs.
          Refer to ray.tune.tune_config.TuneConfig for more info.
      run_config: Runtime configuration that is specific to individual trials.
          If passed, this will overwrite the run config passed to the Trainer,
          if applicable. Refer to ray.train.RunConfig for more info.
  
  Usage pattern:
  
  .. code-block:: python
  
      from sklearn.datasets import load_breast_cancer
  
      from ray import tune
      from ray.data import from_pandas
      from ray.train import RunConfig, ScalingConfig
      from ray.train.xgboost import XGBoostTrainer
      from ray.tune.tuner import Tuner
  
      def get_dataset():
          data_raw = load_breast_cancer(as_frame=True)
          dataset_df = data_raw["data"]
          dataset_df["target"] = data_raw["target"]
          dataset = from_pandas(dataset_df)
          return dataset
  
      trainer = XGBoostTrainer(
          label_column="target",
          params={},
          datasets={"train": get_dataset()},
      )
  
      param_space = {
          "scaling_config": ScalingConfig(
              num_workers=tune.grid_search([2, 4]),
              resources_per_worker={
                  "CPU": tune.grid_search([1, 2]),
              },
          ),
          # You can even grid search various datasets in Tune.
          # "datasets": {
          #     "train": tune.grid_search(
          #         [ds1, ds2]
          #     ),
          # },
          "params": {
              "objective": "binary:logistic",
              "tree_method": "approx",
              "eval_metric": ["logloss", "error"],
              "eta": tune.loguniform(1e-4, 1e-1),
              "subsample": tune.uniform(0.5, 1.0),
              "max_depth": tune.randint(1, 9),
          },
      }
      tuner = Tuner(trainable=trainer, param_space=param_space,
          run_config=RunConfig(name="my_tune_run"))
      results = tuner.fit()
  
  To retry a failed tune run, you can then do
  
  .. code-block:: python
  
      tuner = Tuner.restore(results.experiment_path, trainable=trainer)
      tuner.fit()
  
  ``results.experiment_path`` can be retrieved from the
  :ref:`ResultGrid object <tune-analysis-docs>`. It can
  also be easily seen in the log output from your first run.
class_docstr_tok: ["Tuner","is","the","recommended","way","of","launching","hyperparameter","tuning","jobs","with","Ray","Tune",".","Args",":","trainable",":","The","trainable","to","be","tuned",".","param_space",":","Search","space","of","the","tuning","job",".","One","thing","to","note","is","that","both","preprocessor","and","dataset","can","be","tuned","here",".","tune_config",":","Tuning","algorithm","specific","configs",".","Refer","to","ray.tune.tune_config.TuneConfig","for","more","info",".","run_config",":","Runtime","configuration","that","is","specific","to","individual","trials",".","If","passed",",","this","will","overwrite","the","run","config","passed","to","the","Trainer",",","if","applicable",".","Refer","to","ray.train.RunConfig","for","more","info",".","Usage","pattern",":","..","code-block",":",":","python","from","sklearn.datasets","import","load_breast_cancer","from","ray","import","tune","from","ray.data","import","from_pandas","from","ray.train","import","RunConfig",",","ScalingConfig","from","ray.train.xgboost","import","XGBoostTrainer","from","ray.tune.tuner","import","Tuner","def","get_dataset","(",")",":","data_raw","=","load_breast_cancer","(","as_frame=True",")","dataset_df","=","data_raw","[","``","data","''","]","dataset_df","[","``","target","''","]","=","data_raw","[","``","target","''","]","dataset","=","from_pandas","(","dataset_df",")","return","dataset","trainer","=","XGBoostTrainer","(","label_column=","''","target","''",",","params=","{","}",",","datasets=","{","``","train","''",":","get_dataset","(",")","}",",",")","param_space","=","{","``","scaling_config","''",":","ScalingConfig","(","num_workers=tune.grid_search","(","[","2",",","4","]",")",",","resources_per_worker=","{","``","CPU","''",":","tune.grid_search","(","[","1",",","2","]",")",",","}",",",")",",","#","You","can","even","grid","search","various","datasets","in","Tune",".","#","``","datasets","''",":","{","#","``","train","''",":","tune.grid_search","(","#","[","ds1",",","ds2","]","#",")",",","#","}",",","``","params","''",":","{","``","objective","''",":","``","binary",":","logistic","''",",","``","tree_method","''",":","``","approx","''",",","``","eval_metric","''",":","[","``","logloss","''",",","``","error","''","]",",","``","eta","''",":","tune.loguniform","(","1e-4",",","1e-1",")",",","``","subsample","''",":","tune.uniform","(","0.5",",","1.0",")",",","``","max_depth","''",":","tune.randint","(","1",",","9",")",",","}",",","}","tuner","=","Tuner","(","trainable=trainer",",","param_space=param_space",",","run_config=RunConfig","(","name=","''","my_tune_run","''",")",")","results","=","tuner.fit","(",")","To","retry","a","failed","tune","run",",","you","can","then","do","..","code-block",":",":","python","tuner","=","Tuner.restore","(","results.experiment_path",",","trainable=trainer",")","tuner.fit","(",")","``","results.experiment_path","``","can","be","retrieved","from","the",":","ref",":","`","ResultGrid","object","<","tune-analysis-docs",">","`",".","It","can","also","be","easily","seen","in","the","log","output","from","your","first","run","."]
docstr: Configure and construct a tune run.
docstr_tok: ["Configure","and","construct","a","tune","run","."]
code: def __init__(
      self,
      trainable: Optional[
          Union[str, Callable, Type[Trainable], "BaseTrainer"]
      ] = None,
      *,
      param_space: Optional[Dict[str, Any]] = None,
      tune_config: Optional[TuneConfig] = None,
      run_config: Optional[RunConfig] = None,
      # This is internal only arg.
      # Only for dogfooding purposes. We can slowly promote these args
      # to RunConfig or TuneConfig as needed.
      # TODO(xwjiang): Remove this later.
      _tuner_kwargs: Optional[Dict] = None,
      _tuner_internal: Optional[TunerInternal] = None,
      _entrypoint: AirEntrypoint = AirEntrypoint.TUNER,
  ):
      """Configure and construct a tune run."""
      kwargs = locals().copy()
      self._is_ray_client = ray.util.client.ray.is_connected()
      if self._is_ray_client:
          _run_config = run_config or RunConfig()
          if get_air_verbosity(_run_config.verbose) is not None:
              logger.info(
                  "[output] This uses the legacy output and progress reporter, "
                  "as Ray client is not supported by the new engine. "
                  "For more information, see "
                  "https://github.com/ray-project/ray/issues/36949"
              )
  
      if _tuner_internal:
          if not self._is_ray_client:
              self._local_tuner = kwargs[_TUNER_INTERNAL]
          else:
              self._remote_tuner = kwargs[_TUNER_INTERNAL]
      else:
          kwargs.pop(_TUNER_INTERNAL, None)
          kwargs.pop(_SELF, None)
          if not self._is_ray_client:
              self._local_tuner = TunerInternal(**kwargs)
          else:
              self._remote_tuner = _force_on_current_node(
                  ray.remote(num_cpus=0)(TunerInternal)
              ).remote(**kwargs)
  
imports: import logging
  import os
  from typing import Any, Callable, Dict, Optional, Type, Union, TYPE_CHECKING
  import pyarrow.fs
  import ray
  from ray.air.config import RunConfig
  from ray.air._internal.usage import AirEntrypoint
  from ray.air.util.node import _force_on_current_node
  from ray.train._internal.storage import _exists_at_fs_path, get_fs_and_path
  from ray.tune import TuneError
  from ray.tune.execution.experiment_state import _ResumeConfig
  from ray.tune.experimental.output import get_air_verbosity
  from ray.tune.result_grid import ResultGrid
  from ray.tune.trainable import Trainable
  from ray.tune.impl.tuner_internal import TunerInternal, _TUNER_PKL
  from ray.tune.tune_config import TuneConfig
  from ray.tune.progress_reporter import _prepare_progress_reporter_for_ray_client, _stream_client_output
  from ray.util import PublicAPI
label_desc: Use image node_id 1 to create a new Tuner object  with example: obj = Tuner(trainable)