code: def match_ci_width_truncated(
      mean: float,
      variance: float,
      transform: Callable[[float], float],
      level: float = 0.95,
      margin: float = 0.001,
      lower_bound: float = 0.0,
      upper_bound: float = 1.0,
      clip_mean: bool = False,
  ) -> Tuple[float, float]:
      """Estimate a transformed variance using the match ci width method.
  
      See log_y transform for the original. Here, bounds are forced to lie
      within a [lower_bound, upper_bound] interval after transformation.
      """
      fac = norm.ppf(1 - (1 - level) / 2)
      d = fac * np.sqrt(variance)
      if clip_mean:
          mean = np.clip(
              mean, lower_bound + margin, upper_bound - margin
          )
      right = min(mean + d, upper_bound - margin)
      left = max(mean - d, lower_bound + margin)
      width_asym = transform(right) - transform(left)
      new_mean = transform(mean)
      new_variance = (
          float("nan")
          if isnan(variance)
          else (width_asym / 2 / fac) ** 2
      )
      return new_mean, new_variance
  
imports: from __future__ import annotations
  from collections import defaultdict
  from math import isnan
  from numbers import Number
  from typing import Any, Callable, Dict, List, Optional, Tuple, TYPE_CHECKING, Union
  import numpy
  from ax.core.observation import Observation, ObservationData, ObservationFeatures
  from ax.core.optimization_config import OptimizationConfig
  from ax.core.parameter import Parameter
  from ax.core.parameter_constraint import ParameterConstraint
  from ax.core.search_space import RobustSearchSpace, SearchSpace
  from ax.modelbridge.transforms.derelativize import Derelativize
  from scipy.stats import norm
label_desc: Use image node_id 2 for calling a global function with example usage: match_ci_width_truncated(mean, variance, transform, level, margin, lower_bound, upper_bound, clip_mean) and returns: new_mean,  new_variance