code: def _calc_lim_with_padding(
      values: list[Any], padding_ratio: float, scale: str | None
  ) -> tuple[float, float]:
      value_max = max(values)
      value_min = min(values)
      if scale == "log":
          padding = (
              math.log10(value_max) - math.log10(value_min)
          ) * padding_ratio
          return (
              math.pow(10, math.log10(value_min) - padding),
              math.pow(10, math.log10(value_max) + padding),
          )
      elif scale == "categorical":
          width = len(set(values)) - 1
          padding = width * padding_ratio
          return -padding, width + padding
      else:
          padding = (value_max - value_min) * padding_ratio
          return value_min - padding, value_max + padding
  
file_path: optuna/optuna/visualization/matplotlib/_slice.py
imports: from __future__ import annotations
  from collections import defaultdict
  import math
  from typing import Any
  from typing import Callable
  from optuna._experimental import experimental_func
  from optuna.study import Study
  from optuna.trial import FrozenTrial
  from optuna.visualization._slice import _get_slice_plot_info
  from optuna.visualization._slice import _PlotValues
  from optuna.visualization._slice import _SlicePlotInfo
  from optuna.visualization._slice import _SliceSubplotInfo
  from optuna.visualization.matplotlib._matplotlib_imports import _imports
label_desc: Use image node_id 5 for calling a global function with example usage: _calc_lim_with_padding(values, padding_ratio, scale) and returns: math,  math, unknown,  unknown, unknown,  unknown