class_docstr: The Conditional Value-at-Risk risk measure.
  
  The Conditional Value-at-Risk measures the expectation of the worst outcomes
  (small rewards or large losses) with a total probability of `1 - alpha`. It
  is commonly defined as the conditional expectation of the reward function,
  with the condition that the reward is smaller than the corresponding
  Value-at-Risk (also defined below).
  
  Note: Due to the use of a discrete `w_set` of samples, the VaR and CVaR
      calculated here are (possibly biased) Monte-Carlo approximations of
      the true risk measures.
class_docstr_tok: ["The","Conditional","Value-at-Risk","risk","measure",".","The","Conditional","Value-at-Risk","measures","the","expectation","of","the","worst","outcomes","(","small","rewards","or","large","losses",")","with","a","total","probability","of","`","1","-","alpha","`",".","It","is","commonly","defined","as","the","conditional","expectation","of","the","reward","function",",","with","the","condition","that","the","reward","is","smaller","than","the","corresponding","Value-at-Risk","(","also","defined","below",")",".","Note",":","Due","to","the","use","of","a","discrete","`","w_set","`","of","samples",",","the","VaR","and","CVaR","calculated","here","are","(","possibly","biased",")","Monte-Carlo","approximations","of","the","true","risk","measures","."]
docstr: Calculate the CVaR corresponding to the given samples.
  
  Args:
      samples: A `sample_shape x batch_shape x (q * n_w) x m`-dim tensor of
          posterior samples. The q-batches should be ordered so that each
          `n_w` block of samples correspond to the same input.
      X: A `batch_shape x q x d`-dim tensor of inputs. Ignored.
  
  Returns:
      A `sample_shape x batch_shape x q`-dim tensor of CVaR samples.
docstr_tok: ["Calculate","the","CVaR","corresponding","to","the","given","samples",".","Args",":","samples",":","A","`","sample_shape","x","batch_shape","x","(","q","*","n_w",")","x","m","`","-dim","tensor","of","posterior","samples",".","The","q-batches","should","be","ordered","so","that","each","`","n_w","`","block","of","samples","correspond","to","the","same","input",".","X",":","A","`","batch_shape","x","q","x","d","`","-dim","tensor","of","inputs",".","Ignored",".","Returns",":","A","`","sample_shape","x","batch_shape","x","q","`","-dim","tensor","of","CVaR","samples","."]
code: def forward(
      self, samples: Tensor, X: Optional[Tensor] = None
  ) -> Tensor:
      r"""Calculate the CVaR corresponding to the given samples.
  
      Args:
          samples: A `sample_shape x batch_shape x (q * n_w) x m`-dim tensor of
              posterior samples. The q-batches should be ordered so that each
              `n_w` block of samples correspond to the same input.
          X: A `batch_shape x q x d`-dim tensor of inputs. Ignored.
  
      Returns:
          A `sample_shape x batch_shape x q`-dim tensor of CVaR samples.
      """
      prepared_samples = self._prepare_samples(samples)
      return torch.topk(
          prepared_samples,
          k=prepared_samples.shape[-1] - self.alpha_idx,
          largest=False,
          dim=-1,
      ).values.mean(dim=-1)
  
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 2 for calling the CVaR obj's underlying member method code with example usage: obj.forward(samples, X) and returns: torch