code: def _test_inv_matmul(self, rhs, lhs=None, cholesky=False):
      lazy_tensor = self.create_linear_op().requires_grad_(True)
      lazy_tensor_copy = (
          lazy_tensor.clone().detach_().requires_grad_(True)
      )
      evaluated = self.evaluate_linear_op(lazy_tensor_copy)
      evaluated.register_hook(self._ensure_symmetric_grad)
  
      # Create a test right hand side and left hand side
      rhs.requires_grad_(True)
      rhs_copy = rhs.clone().detach().requires_grad_(True)
      if lhs is not None:
          lhs.requires_grad_(True)
          lhs_copy = lhs.clone().detach().requires_grad_(True)
  
      _wrapped_cg = MagicMock(wraps=linear_operator.utils.linear_cg)
      with patch(
          "linear_operator.utils.linear_cg", new=_wrapped_cg
      ) as linear_cg_mock:
          with gpytorch.settings.max_cholesky_size(
              math.inf if cholesky else 0
          ), gpytorch.settings.cg_tolerance(1e-4):
              # Perform the inv_matmul
              if lhs is not None:
                  res = lazy_tensor.solve(rhs, lhs)
                  actual = lhs_copy @ evaluated.inverse() @ rhs_copy
              else:
                  res = lazy_tensor.solve(rhs)
                  actual = evaluated.inverse().matmul(rhs_copy)
              self.assertAllClose(res, actual, rtol=0.02, atol=1e-5)
  
              # Perform backward pass
              grad = torch.randn_like(res)
              res.backward(gradient=grad)
              actual.backward(gradient=grad)
              for param, param_copy in zip(
                  lazy_tensor.kernel.parameters(),
                  lazy_tensor_copy.kernel.parameters(),
              ):
                  self.assertAllClose(
                      param.grad, param_copy.grad, rtol=1e-3
                  )
              self.assertAllClose(
                  lazy_tensor.x1.grad + lazy_tensor.x2.grad,
                  lazy_tensor_copy.x1.grad + lazy_tensor_copy.x2.grad,
                  rtol=1e-3,
              )
              self.assertAllClose(
                  rhs.grad, rhs_copy.grad, rtol=0.03, atol=1e-5
              )
              if lhs is not None:
                  self.assertAllClose(
                      lhs.grad, lhs_copy.grad, rtol=0.03, atol=1e-5
                  )
  
          # Determine if we've called CG or not
          if not cholesky and self.__class__.should_call_cg:
              self.assertTrue(linear_cg_mock.called)
          else:
              self.assertFalse(linear_cg_mock.called)
  
imports: import math
  import unittest
  from unittest.mock import MagicMock, patch
  import linear_operator
  import torch
  from linear_operator import to_dense
  from linear_operator.test.linear_operator_test_case import LinearOperatorTestCase
  import gpytorch
label_desc: Use image node_id 5 for calling the TestLazyEvaluatedKernelTensorBatch obj's underlying member method code with example usage: obj._test_inv_matmul(rhs, lhs, cholesky) without return types