code: def _get_cutoffs(
      metric_name: str,
      metric_values: List[float],
      winsorization_config: Union[
          WinsorizationConfig, Dict[str, WinsorizationConfig]
      ],
      modelbridge: Optional["modelbridge_module.base.ModelBridge"],
      observations: Optional[List[Observation]],
      optimization_config: Optional[OptimizationConfig],
      use_raw_sq: bool,
  ) -> Tuple[float, float]:
      # (1) Use the same config for all metrics if one WinsorizationConfig was specified
      if isinstance(winsorization_config, WinsorizationConfig):
          return _quantiles_to_cutoffs(
              metric_name=metric_name,
              metric_values=metric_values,
              metric_config=winsorization_config,
          )
  
      # (2) If `winsorization_config` is a dict, use it if `metric_name` is a key,
      # and the corresponding value is a WinsorizationConfig.
      if (
          isinstance(winsorization_config, dict)
          and metric_name in winsorization_config
      ):
          metric_config = winsorization_config[metric_name]
          if not isinstance(metric_config, WinsorizationConfig):
              raise UserInputError(
                  "Expected winsorization config of type "
                  f"`WinsorizationConfig` but got {metric_config} of type "
                  f"{type(metric_config)} for metric {metric_name}."
              )
          return _quantiles_to_cutoffs(
              metric_name=metric_name,
              metric_values=metric_values,
              metric_config=metric_config,
          )
  
      # (3) For constraints and objectives that don't have a pre-specified config we
      # choose the cutoffs automatically using the optimization config (if supplied).
      # We ignore ScalarizedOutcomeConstraint and ScalarizedObjective for now, and
      # derelativize relative constraints if possible.
  
      # When no optimization config is available, return defaults.
      if modelbridge is None or optimization_config is None:
          return DEFAULT_CUTOFFS
      if any(oc.relative for oc in optimization_config.all_constraints):
          if not use_raw_sq:
              raise UnsupportedError(
                  "Automatic winsorization doesn't support relative outcome constraints "
                  "or objective thresholds when `derelativize_with_raw_status_quo` is "
                  "not set to `True`."
              )
          optimization_config = (
              derelativize_optimization_config_with_raw_status_quo(
                  optimization_config=optimization_config,
                  modelbridge=modelbridge,
                  observations=observations,
              )
          )
  
      # Non-objective metrics - obtain cutoffs from outcome_constraints.
      if metric_name not in optimization_config.objective.metric_names:
          # Get all outcome constraints for `metric_name`` that aren't scalarized.
          return _obtain_cutoffs_from_outcome_constraints(
              optimization_config=optimization_config,
              metric_name=metric_name,
              metric_values=metric_values,
          )
  
      # Make sure we winsorize from the correct direction if a `ScalarizedObjective`.
      if isinstance(optimization_config.objective, ScalarizedObjective):
          objective = checked_cast(
              ScalarizedObjective, optimization_config.objective
          )
          weight = [
              w
              for m, w in objective.metric_weights
              if m.name == metric_name
          ][0]
          # Winsorize from above if the weight is positive and minimize is `True` or the
          # weight is negative and minimize is `False`.
          return _get_auto_winsorization_cutoffs_single_objective(
              metric_values=metric_values,
              minimize=objective.minimize
              if weight >= 0
              else not objective.minimize,
          )
  
      # Single-objective
      if not optimization_config.is_moo_problem:
          return _get_auto_winsorization_cutoffs_single_objective(
              metric_values=metric_values,
              minimize=optimization_config.objective.minimize,
          )
  
      # Multi-objective
      return _get_auto_winsorization_cutoffs_multi_objective(
          optimization_config=optimization_config,
          metric_name=metric_name,
          metric_values=metric_values,
      )
  
imports: import warnings
  from logging import Logger
  from typing import Dict, List, Optional, Tuple, TYPE_CHECKING, Union
  import numpy
  from ax.core.objective import MultiObjective, ScalarizedObjective
  from ax.core.observation import Observation, ObservationData
  from ax.core.optimization_config import MultiObjectiveOptimizationConfig, OptimizationConfig
  from ax.core.outcome_constraint import ComparisonOp, ObjectiveThreshold, OutcomeConstraint, ScalarizedOutcomeConstraint
  from ax.core.search_space import SearchSpace
  from ax.exceptions.core import DataRequiredError, UnsupportedError, UserInputError
  from ax.modelbridge.transforms.base import Transform
  from ax.modelbridge.transforms.utils import derelativize_optimization_config_with_raw_status_quo, get_data
  from ax.models.types import TConfig, WinsorizationConfig
  from ax.utils.common.logger import get_logger
  from ax.utils.common.typeutils import checked_cast
label_desc: Use image node_id 1 for calling a global function with example usage: _get_cutoffs(metric_name, metric_values, winsorization_config, modelbridge, observations, optimization_config, use_raw_sq) and returns: _get_auto_winsorization_cutoffs_multi_objective, _quantiles_to_cutoffs, _quantiles_to_cutoffs, DEFAULT_CUTOFFS, _obtain_cutoffs_from_outcome_constraints, _get_auto_winsorization_cutoffs_single_objective, _get_auto_winsorization_cutoffs_single_objective