docstr: Fit the explainer.
  
  The `GradientSimilarity` explainer requires the model gradients over the training data. In the explain method
  it compares them to the model gradients for the test instance(s). If ``precompute_grads=True`` on
  initialization then the gradients are precomputed here and stored. This will speed up the explain method call
  but storing the gradients may not be feasible for large models.
  
  Parameters
  ----------
  X_train
      Training data.
  Y_train
      Training labels.
  
  Returns
  -------
  self
      Returns self.
docstr_tok: ["Fit","the","explainer",".","The","`","GradientSimilarity","`","explainer","requires","the","model","gradients","over","the","training","data",".","In","the","explain","method","it","compares","them","to","the","model","gradients","for","the","test","instance","(","s",")",".","If","``","precompute_grads=True","``","on","initialization","then","the","gradients","are","precomputed","here","and","stored",".","This","will","speed","up","the","explain","method","call","but","storing","the","gradients","may","not","be","feasible","for","large","models",".","Parameters","--","--","--","--","--","X_train","Training","data",".","Y_train","Training","labels",".","Returns","--","--","--","-","self","Returns","self","."]
code: def fit(
      self, X_train: Union[np.ndarray, List[Any]], Y_train: np.ndarray
  ) -> "Explainer":
      """Fit the explainer.
  
      The `GradientSimilarity` explainer requires the model gradients over the training data. In the explain method
      it compares them to the model gradients for the test instance(s). If ``precompute_grads=True`` on
      initialization then the gradients are precomputed here and stored. This will speed up the explain method call
      but storing the gradients may not be feasible for large models.
  
      Parameters
      ----------
      X_train
          Training data.
      Y_train
          Training labels.
  
      Returns
      -------
      self
          Returns self.
      """
      return super().fit(X_train, Y_train)
  
imports: import copy
  import warnings
  from enum import Enum
  from typing import TYPE_CHECKING, Any, Callable, Dict, List, Optional, Tuple, Union
  import numpy
  from alibi.api.defaults import DEFAULT_DATA_SIM, DEFAULT_META_SIM
  from alibi.api.interfaces import Explainer, Explanation
  from alibi.explainers.similarity.base import BaseSimilarityExplainer
  from alibi.explainers.similarity.metrics import asym_dot, cos, dot
  from alibi.utils import _get_options_string
  from alibi.utils.frameworks import Framework
  from typing_extensions import Literal
label_desc: Use image node_id 2 for calling the GradientSimilarity obj's underlying member method code with example usage: obj.fit(X_train, Y_train) and returns: super