class_docstr: Objective transforming the posterior samples to samples of a risk measure.
  
  The risk measure is calculated over joint q-batch samples from the posterior.
  If the q-batch includes samples corresponding to multiple inputs, it is assumed
  that first `n_w` samples correspond to first input, second `n_w` samples
  correspond to second input etc.
  
  The risk measures are commonly defined for minimization by considering the
  upper tail of the distribution, i.e., treating larger values as being undesirable.
  BoTorch by default assumes a maximization objective, so the default behavior here
  is to calculate the risk measures w.r.t. the lower tail of the distribution.
  This can be changed by passing a preprocessing function with
  `weights=torch.tensor([-1.0])`.
  
  :meta private:
class_docstr_tok: ["Objective","transforming","the","posterior","samples","to","samples","of","a","risk","measure",".","The","risk","measure","is","calculated","over","joint","q-batch","samples","from","the","posterior",".","If","the","q-batch","includes","samples","corresponding","to","multiple","inputs",",","it","is","assumed","that","first","`","n_w","`","samples","correspond","to","first","input",",","second","`","n_w","`","samples","correspond","to","second","input","etc",".","The","risk","measures","are","commonly","defined","for","minimization","by","considering","the","upper","tail","of","the","distribution",",","i.e.",",","treating","larger","values","as","being","undesirable",".","BoTorch","by","default","assumes","a","maximization","objective",",","so","the","default","behavior","here","is","to","calculate","the","risk","measures","w.r.t",".","the","lower","tail","of","the","distribution",".","This","can","be","changed","by","passing","a","preprocessing","function","with","`","weights=torch.tensor","(","[","-1.0","]",")","`",".",":","meta","private",":"]
docstr: Transform the posterior samples to samples of a risk measure.
  
  Args:
      n_w: The size of the `w_set` to calculate the risk measure over.
      preprocessing_function: A preprocessing function to apply to the samples
          before computing the risk measure. This can be used to scalarize
          multi-output samples before calculating the risk measure.
          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`-dim tensor.
docstr_tok: ["Transform","the","posterior","samples","to","samples","of","a","risk","measure",".","Args",":","n_w",":","The","size","of","the","`","w_set","`","to","calculate","the","risk","measure","over",".","preprocessing_function",":","A","preprocessing","function","to","apply","to","the","samples","before","computing","the","risk","measure",".","This","can","be","used","to","scalarize","multi-output","samples","before","calculating","the","risk","measure",".","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","`","-dim","tensor","."]
code: def __init__(
      self,
      n_w: int,
      preprocessing_function: Optional[
          Callable[[Tensor], Tensor]
      ] = None,
  ) -> None:
      r"""Transform the posterior samples to samples of a risk measure.
  
      Args:
          n_w: The size of the `w_set` to calculate the risk measure over.
          preprocessing_function: A preprocessing function to apply to the samples
              before computing the risk measure. This can be used to scalarize
              multi-output samples before calculating the risk measure.
              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`-dim tensor.
      """
      super().__init__()
      self.n_w = n_w
      if preprocessing_function is None:
          if self._is_mo:
              preprocessing_function = IdentityMCMultiOutputObjective()
          else:
              preprocessing_function = IdentityMCObjective()
      self.preprocessing_function = preprocessing_function
  
imports: from abc import ABC, abstractmethod
  from math import ceil
  from typing import Callable, Optional
  import torch
  from botorch.acquisition.multi_objective.objective import IdentityMCMultiOutputObjective
  from botorch.acquisition.objective import IdentityMCObjective, MCAcquisitionObjective
  from torch import Tensor
label_desc: Use image node_id 1 to create a new RiskMeasureMCObjective object from inherited base classes: MCAcquisitionObjective, ABC with example: obj = RiskMeasureMCObjective(n_w, preprocessing_function)