code: def inv_quad(
      input: Anysor, inv_quad_rhs: Tensor, reduce_inv_quad: bool = True
  ) -> Tensor:
      r"""
      Computes an inverse quadratic form (w.r.t self) with several right hand sides, i.e:
  
      .. math::
         \text{tr}\left( \mathbf R^\top \mathbf A^{-1} \mathbf R \right),
  
      where :math:`\mathbf A` is a positive definite matrix (or batch of matrices) and :math:`\mathbf R`
      represents the right hand sides (:attr:`inv_quad_rhs`).
  
      If :attr:`reduce_inv_quad` is set to false (and :attr:`inv_quad_rhs` is supplied),
      the function instead computes
  
      .. math::
         \text{diag}\left( \mathbf R^\top \mathbf A^{-1} \mathbf R \right).
  
      :param input: :math:`\mathbf A` - the positive definite matrix (... X N X N)
      :param inv_quad_rhs: :math:`\mathbf R` - the right hand sides of the inverse quadratic term (... x N x M)
      :param reduce_inv_quad: Whether to compute
          :math:`\text{tr}\left( \mathbf R^\top \mathbf A^{-1} \mathbf R \right)`
          or :math:`\text{diag}\left( \mathbf R^\top \mathbf A^{-1} \mathbf R \right)`.
      :returns: The inverse quadratic term.
          If `reduce_inv_quad=True`, the inverse quadratic term is of shape (...). Otherwise, it is (... x M).
      """
      return linear_operator.inv_quad(
          input=input,
          inv_quad_rhs=inv_quad_rhs,
          reduce_inv_quad=reduce_inv_quad,
      )
  
imports: from typing import Optional, Tuple, Union
  import linear_operator
  import torch
  from linear_operator import LinearOperator
  from torch import Tensor
  from .None import beta_features, distributions, kernels, lazy, likelihoods, means, metrics, mlls, models, optim, priors, settings, utils, variational
  from .functions import inv_matmul, log_normal_cdf, logdet, matmul
  from .lazy import cat, delazify, lazify
  from .mlls import ExactMarginalLogLikelihood
  from .module import Module
label_desc: Use image node_id 5 for calling a global function with example usage: inv_quad(input, inv_quad_rhs, reduce_inv_quad) and returns: linear_operator