code: def test_extract_risk_measure(self) -> None:
      rm = RiskMeasure(
          risk_measure="VaR",
          options={"alpha": 0.8, "n_w": 5},
      )
      rm_module = extract_risk_measure(risk_measure=rm)
      self.assertIsInstance(rm_module, VaR)
      self.assertEqual(rm_module.alpha, 0.8)
      self.assertEqual(rm_module.n_w, 5)
  
      # Test unknown risk measure.
      with self.assertRaisesRegex(UserInputError, "constructing"):
          extract_risk_measure(
              risk_measure=RiskMeasure(
                  risk_measure="VVar",
                  options={},
              )
          )
      # Test invalid options.
      with self.assertRaisesRegex(UserInputError, "constructing"):
          extract_risk_measure(
              risk_measure=RiskMeasure(
                  risk_measure="VaR",
                  options={"alpha": 5, "n_w": 5},
              )
          )
  
      # Test using user-defined risk measures.
  
      class CustomRM(VaR):
          pass
  
      RISK_MEASURE_NAME_TO_CLASS["custom"] = CustomRM
  
      rm = RiskMeasure(
          risk_measure="custom",
          options={"alpha": 0.8, "n_w": 5},
      )
      self.assertEqual(rm.risk_measure, "custom")
      self.assertIsInstance(
          extract_risk_measure(risk_measure=rm), CustomRM
      )
  
imports: from dataclasses import dataclass
  from typing import List, Union
  import numpy
  import torch
  from ax.core.metric import Metric
  from ax.core.objective import MultiObjective
  from ax.core.optimization_config import MultiObjectiveOptimizationConfig
  from ax.core.outcome_constraint import ObjectiveThreshold, OutcomeConstraint
  from ax.core.parameter import ChoiceParameter, ParameterType, RangeParameter
  from ax.core.risk_measures import RiskMeasure
  from ax.core.search_space import RobustSearchSpace, SearchSpace
  from ax.core.types import ComparisonOp
  from ax.exceptions.core import UserInputError
  from ax.modelbridge.modelbridge_utils import _array_to_tensor, extract_risk_measure, extract_robust_digest, feasible_hypervolume, process_contextual_datasets, RISK_MEASURE_NAME_TO_CLASS, transform_search_space
  from ax.modelbridge.registry import Cont_X_trans, Y_trans
  from ax.utils.common.testutils import TestCase
  from ax.utils.common.typeutils import not_none
  from ax.utils.testing.core_stubs import get_robust_search_space, get_search_space
  from botorch.acquisition.risk_measures import VaR
  from botorch.utils.datasets import ContextualDataset, SupervisedDataset
label_desc: Use image node_id 2 for calling the TestModelBridgeUtils obj's underlying member method code with example usage: obj.test_extract_risk_measure() without return types