code: def test_errors(self):
      matrix = self.matrix
      diag = self.diag
      diag = matrix.diagonal(dim1=-2, dim2=-1).sqrt()
      idiag = diag.reciprocal().unsqueeze(-1)
      n = matrix.shape[-1]
  
      # testing with erroneous inputs
      wrong_matrix = matrix[..., 0]
      error_msg = "Expected square matrices but `matrix` has shape.*"
      with self.assertRaisesRegex(ValueError, error_msg):
          PivotedCholesky(
              step=0,
              tril=wrong_matrix,
              perm=torch.arange(n)[None]
              .expand(len(matrix), n)
              .contiguous(),
              diag=diag.clone(),
              validate_init=True,
          )
  
      wrong_perm = (
          torch.arange(n)[None].expand(2 * len(matrix), n).contiguous()
      )
      error_msg = (
          "`perm` of shape .* incompatible with `matrix` of shape .*"
      )
      with self.assertRaisesRegex(ValueError, error_msg):
          PivotedCholesky(
              step=0,
              tril=(idiag * matrix * idiag.transpose(-2, -1)).tril(),
              perm=wrong_perm,
              diag=diag.clone(),
          )
  
      wrong_diag = torch.ones(2 * len(diag))
      error_msg = (
          "`diag` of shape .* incompatible with `matrix` of shape .*"
      )
      with self.assertRaises(ValueError, msg=error_msg):
          PivotedCholesky(
              step=0,
              tril=(idiag * matrix * idiag.transpose(-2, -1)).tril(),
              perm=torch.arange(n)[None]
              .expand(len(matrix), n)
              .contiguous(),
              diag=wrong_diag,
          )
  
      # testing without validation, should pass,
      # even though input does not have correct shape
      piv_chol = PivotedCholesky(
          step=0,
          tril=matrix[..., 0],
          perm=torch.arange(n)[None]
          .expand(len(matrix), n)
          .contiguous(),
          diag=diag.clone(),
          validate_init=False,
      )
      self.assertTrue(isinstance(piv_chol, PivotedCholesky))
  
file_path: botorch/test/utils/probability/test_linalg.py
imports: from __future__ import annotations
  from copy import deepcopy
  import torch
  from botorch.utils.probability.linalg import augment_cholesky, PivotedCholesky
  from botorch.utils.testing import BotorchTestCase
label_desc: Use image node_id 9 for calling the TestPivotedCholesky obj's underlying member method code with example usage: obj.test_errors() without return types