code: def pivot_(self, pivot: LongTensor) -> None:
      *batch_shape, _, size = self.tril.shape
      if pivot.shape != tuple(batch_shape):
          raise ValueError(
              "Argument `pivot` does to match with batch shape`."
          )
  
      # Perform basic swaps
      for key in ("perm", "diag"):
          tnsr = getattr(self, key, None)
          if tnsr is not None:
              swap_along_dim_(
                  tnsr, i=self.step, j=pivot, dim=tnsr.ndim - 1
              )
  
      # Perform matrix swaps; prealloacte buffers for row/column linear indices
      size2 = size**2
      min_pivot = pivot.min()
      tkwargs = {"device": pivot.device, "dtype": pivot.dtype}
      buffer_col = torch.arange(
          size * (1 + min_pivot), size2, size, **tkwargs
      )
      buffer_row = torch.arange(
          0, max(self.step, pivot.max()), **tkwargs
      )
      head = buffer_row[: self.step]
  
      indices_v1 = []
      indices_v2 = []
      for i, piv in enumerate(pivot.view(-1, 1)):
          v1 = pad(piv, (1, 0), value=self.step).unsqueeze(-1)
          v2 = pad(piv, (0, 1), value=self.step).unsqueeze(-1)
          start = i * size2
  
          indices_v1.extend((start + v1 + size * v1).ravel())
          indices_v2.extend((start + v2 + size * v2).ravel())
  
          indices_v1.extend((start + size * v1 + head).ravel())
          indices_v2.extend((start + size * v2 + head).ravel())
  
          tail = buffer_col[piv - min_pivot :]
          indices_v1.extend((start + v1 + tail).ravel())
          indices_v2.extend((start + v2 + tail).ravel())
  
          interior = buffer_row[min(piv, self.step + 1) : piv]
          indices_v1.extend(start + size * interior + self.step)
          indices_v2.extend(start + size * piv + interior)
  
      swap_along_dim_(
          self.tril.view(-1),
          i=torch.as_tensor(indices_v1, **tkwargs),
          j=torch.as_tensor(indices_v2, **tkwargs),
          dim=0,
      )
  
file_path: botorch/botorch/utils/probability/linalg.py
imports: from __future__ import annotations
  from dataclasses import dataclass, InitVar
  from itertools import chain
  from typing import Any, Optional, Sequence
  import torch
  from botorch.utils.probability.utils import swap_along_dim_
  from linear_operator.utils.errors import NotPSDError
  from torch import LongTensor, Tensor
  from torch.nn.functional import pad
label_desc: Use image node_id 4 for calling the PivotedCholesky obj's underlying member method code with example usage: obj.pivot_(pivot) without return types