code: def _untransform_numerical_param(
      trans_param: float,
      distribution: BaseDistribution,
      transform_log: bool,
  ) -> Union[int, float]:
      d = distribution
  
      if isinstance(d, CategoricalDistribution):
          assert False, "Should not reach. Should be one-hot encoded."
      elif isinstance(d, FloatDistribution):
          if d.log:
              param = (
                  math.exp(trans_param)
                  if transform_log
                  else trans_param
              )
              if d.single():
                  pass
              else:
                  param = min(
                      param, numpy.nextafter(d.high, d.high - 1)
                  )
          elif d.step is not None:
              param = float(
                  numpy.clip(
                      numpy.round((trans_param - d.low) / d.step)
                      * d.step
                      + d.low,
                      d.low,
                      d.high,
                  )
              )
          else:
              if d.single():
                  param = trans_param
              else:
                  param = min(
                      trans_param, numpy.nextafter(d.high, d.high - 1)
                  )
      elif isinstance(d, IntDistribution):
          if d.log:
              if transform_log:
                  param = int(
                      numpy.clip(
                          numpy.round(math.exp(trans_param)),
                          d.low,
                          d.high,
                      )
                  )
              else:
                  param = int(trans_param)
          else:
              param = int(
                  numpy.clip(
                      numpy.round((trans_param - d.low) / d.step)
                      * d.step
                      + d.low,
                      d.low,
                      d.high,
                  )
              )
      else:
          assert False, "Should not reach. Unexpected distribution."
  
      return param
  
imports: import math
  from typing import Any
  from typing import Dict
  from typing import List
  from typing import Tuple
  from typing import Union
  import numpy
  from optuna.distributions import BaseDistribution
  from optuna.distributions import CategoricalDistribution
  from optuna.distributions import FloatDistribution
  from optuna.distributions import IntDistribution
label_desc: Use image node_id 3 for calling a global function with example usage: _untransform_numerical_param(trans_param, distribution, transform_log) and returns: param