code: def test_cvar(self):
      obj = CVaR(alpha=0.5, n_w=3)
      self.assertEqual(obj.alpha_idx, 1)
      with self.assertRaises(ValueError):
          CVaR(alpha=3, n_w=3)
      for dtype in (torch.float, torch.double):
          obj = CVaR(alpha=0.5, n_w=3)
          samples = torch.tensor(
              [[[1.0], [0.5], [2.0], [3.0], [1.0], [5.0]]],
              device=self.device,
              dtype=dtype,
          )
          rm_samples = obj(samples)
          self.assertTrue(
              torch.equal(
                  rm_samples,
                  torch.tensor(
                      [[0.75, 2.0]], device=self.device, dtype=dtype
                  ),
              )
          )
          # w/ preprocessing function
          obj = CVaR(
              alpha=0.5,
              n_w=3,
              preprocessing_function=LinearMCObjective(
                  weights=torch.tensor(
                      [-1.0], device=self.device, dtype=dtype
                  )
              ),
          )
          rm_samples = obj(samples)
          self.assertTrue(
              torch.equal(
                  rm_samples,
                  torch.tensor(
                      [[-1.5, -4.0]], device=self.device, dtype=dtype
                  ),
              )
          )
  
imports: from typing import Optional
  import torch
  from botorch.acquisition.objective import LinearMCObjective
  from botorch.acquisition.risk_measures import CVaR, Expectation, RiskMeasureMCObjective, VaR, WorstCase
  from botorch.utils.testing import BotorchTestCase
  from torch import Tensor
label_desc: Use image node_id 1 for calling the TestCVaR obj's underlying member method code with example usage: obj.test_cvar() without return types