class_docstr: The multivariate Value-at-Risk as introduced in [Prekopa2012MVaR]_.
  
  MVaR is defined as the non-dominated set of points in the extended domain
  of the random variable that have multivariate CDF greater than or equal to
  `alpha`. Note that MVaR is set valued and the size of the set depends on the
  particular realizations of the random variable. [Cousin2013MVaR]_ instead
  propose to use the expectation of the set-valued MVaR as the multivariate
  VaR. We support this alternative with an `expectation` flag.
  
  This supports approximate gradients as discussed in [Daulton2022MARS]_.
docstr: The multivariate Value-at-Risk.
  
  Args:
      n_w: The size of the `w_set` to calculate the risk measure over.
      alpha: The risk level of MVaR, float in `(0.0, 1.0]`. Each MVaR value
          dominates `alpha` fraction of all observations.
      expectation: If True, returns the expectation of the MVaR set as is
          done in [Cousin2013MVaR]_. Otherwise, it returns the union of all
          values in the MVaR set. Default: False.
      preprocessing_function: A preprocessing function to apply to the
          samples before computing the risk measure. This can be used to
          remove non-objective outcomes or to align all outcomes for
          maximization. For constrained optimization, this should also
          apply feasibility-weighting to samples. Given a `batch x m`-dim
          tensor of samples, this should return a `batch x m'`-dim tensor.
      pad_to_n_w: If True, instead of padding up to `k'`, which is the size of
          the largest MVaR set across all batches, we pad the MVaR set up to
          `n_w`. This produces a return tensor of known size, however, it may
          in general be much larger than the alternative. See `forward` for
          more details on the return shape.
          NOTE: this is only relevant if `expectation=False`.
      filter_dominated: If True, returns the non-dominated subset of
          alpha level points (this is MVaR as defined by [Prekopa2012MVaR]_).
          Disabling this will make it faster, and may be preferable if
          the dominated points will be filtered out later, e.g., while
          calculating the hypervolume. Disabling this is not recommended
          if `expectation=True`.
      use_counting: If True, uses `get_mvar_set_via_counting` for finding the
          MVaR set. This is method is less memory intensive than the vectorized
          implementation, which is beneficial when `n_w` is quite large.
docstr_tok: ["The","multivariate","Value-at-Risk",".","Args",":","n_w",":","The","size","of","the","`","w_set","`","to","calculate","the","risk","measure","over",".","alpha",":","The","risk","level","of","MVaR",",","float","in","`","(","0.0",",","1.0","]","`",".","Each","MVaR","value","dominates","`","alpha","`","fraction","of","all","observations",".","expectation",":","If","True",",","returns","the","expectation","of","the","MVaR","set","as","is","done","in","[","Cousin2013MVaR","]","_",".","Otherwise",",","it","returns","the","union","of","all","values","in","the","MVaR","set",".","Default",":","False",".","preprocessing_function",":","A","preprocessing","function","to","apply","to","the","samples","before","computing","the","risk","measure",".","This","can","be","used","to","remove","non-objective","outcomes","or","to","align","all","outcomes","for","maximization",".","For","constrained","optimization",",","this","should","also","apply","feasibility-weighting","to","samples",".","Given","a","`","batch","x","m","`","-dim","tensor","of","samples",",","this","should","return","a","`","batch","x","m","'","`","-dim","tensor",".","pad_to_n_w",":","If","True",",","instead","of","padding","up","to","`","k","'","`",",","which","is","the","size","of","the","largest","MVaR","set","across","all","batches",",","we","pad","the","MVaR","set","up","to","`","n_w","`",".","This","produces","a","return","tensor","of","known","size",",","however",",","it","may","in","general","be","much","larger","than","the","alternative",".","See","`","forward","`","for","more","details","on","the","return","shape",".","NOTE",":","this","is","only","relevant","if","`","expectation=False","`",".","filter_dominated",":","If","True",",","returns","the","non-dominated","subset","of","alpha","level","points","(","this","is","MVaR","as","defined","by","[","Prekopa2012MVaR","]","_",")",".","Disabling","this","will","make","it","faster",",","and","may","be","preferable","if","the","dominated","points","will","be","filtered","out","later",",","e.g.",",","while","calculating","the","hypervolume",".","Disabling","this","is","not","recommended","if","`","expectation=True","`",".","use_counting",":","If","True",",","uses","`","get_mvar_set_via_counting","`","for","finding","the","MVaR","set",".","This","is","method","is","less","memory","intensive","than","the","vectorized","implementation",",","which","is","beneficial","when","`","n_w","`","is","quite","large","."]
code: def __init__(
      self,
      n_w: int,
      alpha: float,
      expectation: bool = False,
      preprocessing_function: Optional[
          Callable[[Tensor], Tensor]
      ] = None,
      *,
      pad_to_n_w: bool = False,
      filter_dominated: bool = True,
      use_counting: bool = False,
  ) -> None:
      r"""The multivariate Value-at-Risk.
  
      Args:
          n_w: The size of the `w_set` to calculate the risk measure over.
          alpha: The risk level of MVaR, float in `(0.0, 1.0]`. Each MVaR value
              dominates `alpha` fraction of all observations.
          expectation: If True, returns the expectation of the MVaR set as is
              done in [Cousin2013MVaR]_. Otherwise, it returns the union of all
              values in the MVaR set. Default: False.
          preprocessing_function: A preprocessing function to apply to the
              samples before computing the risk measure. This can be used to
              remove non-objective outcomes or to align all outcomes for
              maximization. For constrained optimization, this should also
              apply feasibility-weighting to samples. Given a `batch x m`-dim
              tensor of samples, this should return a `batch x m'`-dim tensor.
          pad_to_n_w: If True, instead of padding up to `k'`, which is the size of
              the largest MVaR set across all batches, we pad the MVaR set up to
              `n_w`. This produces a return tensor of known size, however, it may
              in general be much larger than the alternative. See `forward` for
              more details on the return shape.
              NOTE: this is only relevant if `expectation=False`.
          filter_dominated: If True, returns the non-dominated subset of
              alpha level points (this is MVaR as defined by [Prekopa2012MVaR]_).
              Disabling this will make it faster, and may be preferable if
              the dominated points will be filtered out later, e.g., while
              calculating the hypervolume. Disabling this is not recommended
              if `expectation=True`.
          use_counting: If True, uses `get_mvar_set_via_counting` for finding the
              MVaR set. This is method is less memory intensive than the vectorized
              implementation, which is beneficial when `n_w` is quite large.
      """
      super().__init__(
          n_w=n_w, preprocessing_function=preprocessing_function
      )
      if not 0 < alpha <= 1:
          raise ValueError("`alpha` must be in (0.0, 1.0]")
      self.alpha = alpha
      self.expectation = expectation
      self.pad_to_n_w = pad_to_n_w
      self.filter_dominated = filter_dominated
      self.use_counting = use_counting
  
imports: import warnings
  from abc import ABC, abstractmethod
  from math import ceil
  from typing import Callable, List, Optional, Union
  import torch
  from botorch.acquisition.multi_objective.objective import IdentityMCMultiOutputObjective, MCMultiOutputObjective
  from botorch.acquisition.risk_measures import CVaR, RiskMeasureMCObjective, VaR
  from botorch.exceptions.errors import UnsupportedError
  from botorch.exceptions.warnings import BotorchWarning
  from botorch.models.model import Model
  from botorch.utils.multi_objective.pareto import is_non_dominated
  from botorch.utils.transforms import normalize
  from torch import Tensor
label_desc: Use image node_id 1 to create a new MVaR object from inherited base classes: MultiOutputRiskMeasureMCObjective with example: obj = MVaR(n_w, alpha, expectation, preprocessing_function)