code: def sample_sac_params(trial: optuna.Trial) -> dict[str, Any]:
      """
      Sampler for SAC hyperparams.
  
      :param trial:
      :return:
      """
      gamma = trial.suggest_categorical(
          "gamma", [0.9, 0.95, 0.98, 0.99, 0.995, 0.999, 0.9999]
      )
      learning_rate = trial.suggest_loguniform("learning_rate", 1e-5, 1)
      batch_size = trial.suggest_categorical(
          "batch_size", [16, 32, 64, 128, 256, 512, 1024, 2048]
      )
      buffer_size = trial.suggest_categorical(
          "buffer_size", [int(1e4), int(1e5), int(1e6)]
      )
      learning_starts = trial.suggest_categorical(
          "learning_starts", [0, 1000, 10000, 20000]
      )
      # train_freq = trial.suggest_categorical('train_freq', [1, 10, 100, 300])
      train_freq = trial.suggest_categorical(
          "train_freq", [1, 4, 8, 16, 32, 64, 128, 256, 512]
      )
      # Polyak coeff
      tau = trial.suggest_categorical(
          "tau", [0.001, 0.005, 0.01, 0.02, 0.05, 0.08]
      )
      # gradient_steps takes too much time
      # gradient_steps = trial.suggest_categorical('gradient_steps', [1, 100, 300])
      gradient_steps = train_freq
      # ent_coef = trial.suggest_categorical('ent_coef', ['auto', 0.5, 0.1, 0.05, 0.01, 0.0001])
      ent_coef = "auto"
      # You can comment that out when not using gSDE
      log_std_init = trial.suggest_uniform("log_std_init", -4, 1)
      # NOTE: Add "verybig" to net_arch when tuning HER
      net_arch = trial.suggest_categorical(
          "net_arch", ["small", "medium", "big"]
      )
      # activation_fn = trial.suggest_categorical('activation_fn', [nn.Tanh, nn.ReLU, nn.ELU, nn.LeakyReLU])
  
      net_arch = {
          "small": [64, 64],
          "medium": [256, 256],
          "big": [400, 300],
          # Uncomment for tuning HER
          # "large": [256, 256, 256],
          # "verybig": [512, 512, 512],
      }[net_arch]
  
      target_entropy = "auto"
      # if ent_coef == 'auto':
      #     # target_entropy = trial.suggest_categorical('target_entropy', ['auto', 5, 1, 0, -1, -5, -10, -20, -50])
      #     target_entropy = trial.suggest_uniform('target_entropy', -10, 10)
  
      hyperparams = {
          "gamma": gamma,
          "learning_rate": learning_rate,
          "batch_size": batch_size,
          "buffer_size": buffer_size,
          "learning_starts": learning_starts,
          "train_freq": train_freq,
          "gradient_steps": gradient_steps,
          "ent_coef": ent_coef,
          "tau": tau,
          "target_entropy": target_entropy,
          "policy_kwargs": dict(
              log_std_init=log_std_init, net_arch=net_arch
          ),
      }
  
      if trial.using_her_replay_buffer:
          hyperparams = sample_her_params(trial, hyperparams)
  
      return hyperparams
  
file_path: FinRL/finrl/agents/stablebaselines3/hyperparams_opt.py
imports: from __future__ import annotations
  from typing import Any
  from typing import Dict
  import numpy
  import optuna
  from stable_baselines3.common.noise import NormalActionNoise
  from stable_baselines3.common.noise import OrnsteinUhlenbeckActionNoise
  from torch import nn
  from utils import linear_schedule
label_desc: Use image node_id 4 for calling a global function with example usage: sample_sac_params(trial) and returns: hyperparams