code: def __init__(self, api_config: ApiConfig, **kwargs: Any) -> None:
      super().__init__(api_config, **kwargs)
  
      try:
          sampler = _SAMPLERS[kwargs["sampler"]]
          sampler_kwargs: dict[str, Any] = kwargs["sampler_kwargs"]
  
      except KeyError:
          raise ValueError(
              "Unknown sampler passed to Optuna optimizer."
          )
  
      try:
          pruner = _PRUNERS[kwargs["pruner"]]
          pruner_kwargs: dict[str, Any] = kwargs["pruner_kwargs"]
  
      except KeyError:
          raise ValueError("Unknown pruner passed to Optuna optimizer.")
  
      # We are using negative log-likelihood for classification
      # and MSE for regression. Both are minimized.
      self.study = optuna.create_study(
          direction="minimize",
          sampler=sampler(**sampler_kwargs),
          pruner=pruner(**pruner_kwargs),
      )
      self.current_trials: dict[int, int] = dict()
  
file_path: optuna/benchmarks/bayesmark/optuna_optimizer.py
imports: from __future__ import annotations
  from typing import Any
  from typing import Dict
  from typing import Union
  import numpy
  from bayesmark.abstract_optimizer import AbstractOptimizer
  from bayesmark.experiment import experiment_main
  import optuna
  from optuna import pruners
  from optuna import samplers
  from optuna.integration.botorch import BoTorchSampler
  from optuna.integration.cma import PyCmaSampler
label_desc: Use image node_id 1 to create a new OptunaOptimizer object from inherited base classes: AbstractOptimizer with example: obj = OptunaOptimizer(api_config)