docstr: Formats `X`, `Y` for explain method.
  
  Parameters
  ----------
  X
      Input data requiring formatting.
  Y
      Target data requiring formatting.
  
  Returns
  -------
  X
      Input data formatted for explain method.
  Y
      Target data formatted for explain method.
docstr_tok: ["Formats","`","X","`",",","`","Y","`","for","explain","method",".","Parameters","--","--","--","--","--","X","Input","data","requiring","formatting",".","Y","Target","data","requiring","formatting",".","Returns","--","--","--","-","X","Input","data","formatted","for","explain","method",".","Y","Target","data","formatted","for","explain","method","."]
code: def _preprocess_args(
      self,
      X: "Union[np.ndarray, tensorflow.Tensor, torch.Tensor, Any, List[Any]]",
      Y: "Optional[Union[np.ndarray, tensorflow.Tensor, torch.Tensor]]" = None,
  ) -> "Union[Tuple[torch.Tensor, torch.Tensor], Tuple[tensorflow.Tensor, tensorflow.Tensor]]":
      """Formats `X`, `Y` for explain method.
  
      Parameters
      ----------
      X
          Input data requiring formatting.
      Y
          Target data requiring formatting.
  
      Returns
      -------
      X
          Input data formatted for explain method.
      Y
          Target data formatted for explain method.
  
      """
      X = self._match_shape_to_data(X, "X")
      if isinstance(X, np.ndarray):
          X = self.backend.to_tensor(X)
  
      if self.task == Task.REGRESSION and Y is None:
          err_msg = "Regression task requires a target value. 'Y' must be provided."
          raise ValueError(err_msg)
  
      if Y is None:
          Y = self.predictor(X)
          Y = self.backend.argmax(Y)  # type: ignore
  
      Y = self._match_shape_to_data(Y, "Y")
      if isinstance(Y, np.ndarray):
          Y = self.backend.to_tensor(Y)
  
      return X, Y
  
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 3 for calling the GradientSimilarity obj's underlying member method code with example usage: obj._preprocess_args(X, Y) and returns: X,  Y