class_docstr: Base class for similarity explainers.
docstr: Computes predictor parameter gradients and returns a flattened `numpy` array.
docstr_tok: ["Computes","predictor","parameter","gradients","and","returns","a","flattened","`","numpy","`","array","."]
code: def _compute_grad(
      self,
      X: "Union[np.ndarray, tensorflow.Tensor, torch.Tensor, List[Any]]",
      Y: "Union[np.ndarray, tensorflow.Tensor, torch.Tensor]",
  ) -> np.ndarray:
      """Computes predictor parameter gradients and returns a flattened `numpy` array."""
      X = self.backend.to_tensor(X) if isinstance(X, np.ndarray) else X
      Y = self.backend.to_tensor(Y) if isinstance(Y, np.ndarray) else Y
      return self.backend.get_grads(self.predictor, X, Y, self.loss_fn)
  
imports: from abc import ABC
  from typing import TYPE_CHECKING, Any, Callable, List, Optional, Union
  import numpy
  from alibi.api.interfaces import Explainer
  from alibi.explainers.similarity.backends import _select_backend
  from alibi.utils.frameworks import Framework, has_pytorch, has_tensorflow
  from alibi.utils.missing_optional_dependency import import_optional
  from tqdm import tqdm
  from typing_extensions import Literal
label_desc: Use image node_id 10 for calling the BaseSimilarityExplainer obj's underlying member method code with example usage: obj._compute_grad(X, Y) and returns: self