code: def tune_torch(
      num_workers: int = 4,
      num_trials: int = 8,
      use_gpu: bool = False,
      config: Optional[Dict] = None,
  ):
      """Making sure that tuning multiple trials in parallel is not
      taking significantly longer than training each one individually.
  
      Some overhead is expected.
      """
  
      from ray import tune
      from ray.tune.tuner import Tuner
      from ray.tune.tune_config import TuneConfig
  
      param_space = {
          "train_loop_config": {
              "lr": tune.loguniform(1e-4, 1e-1),
          },
      }
  
      trainer = get_trainer(
          num_workers=num_workers, use_gpu=use_gpu, config=config
      )
      tuner = Tuner(
          trainable=trainer,
          param_space=param_space,
          tune_config=TuneConfig(
              mode="min", metric="loss", num_samples=num_trials
          ),
      )
      tuner.fit()
  
file_path: ray/release/air_tests/air_benchmarks/workloads/tune_torch_benchmark.py
imports: import json
  import os
  import time
  import timeit
  from typing import Optional, Dict
  import click
  import numpy
  import ray
  from ray.train import ScalingConfig
  from ray.train.torch import TorchTrainer
label_desc: Use image node_id 4 for calling a global function with example usage: tune_torch(num_workers, num_trials, use_gpu, config) without return types