code: def run_optuna_tune(smoke_test=False):
      algo = OptunaSearch(
          space=define_by_run_func, metric="mean_loss", mode="min"
      )
      algo = ConcurrencyLimiter(algo, max_concurrent=4)
      scheduler = AsyncHyperBandScheduler()
      tuner = tune.Tuner(
          easy_objective,
          tune_config=tune.TuneConfig(
              metric="mean_loss",
              mode="min",
              search_alg=algo,
              scheduler=scheduler,
              num_samples=10 if smoke_test else 100,
          ),
      )
      results = tuner.fit()
  
      print(
          "Best hyperparameters found were: ",
          results.get_best_result().config,
      )
  
file_path: ray/python/ray/tune/examples/optuna_define_by_run_example.py
imports: import time
  from typing import Dict, Optional, Any
  import ray
  from ray import train, tune
  from ray.tune.search import ConcurrencyLimiter
  from ray.tune.schedulers import AsyncHyperBandScheduler
  from ray.tune.search.optuna import OptunaSearch
label_desc: Use image node_id 4 for calling a global function with example usage: run_optuna_tune(smoke_test) without return types