class_docstr: Base class for similarity explainers.
docstr: Verify the shape of `data` against the shape of the training data.
  
  Used to ensure input is correct shape for gradient methods implemented in the backends. `data` will be the
  features or label of the instance being explained. If the `data` is not a batch, reshape to be a single batch
  element. i.e. if training data shape is `(3, 28, 28)` and data shape is `(3, 28, 28)` we reshape data to
  `(1, 3, 28, 28)`.
  
  Parameters
  ----------
  data
      Data to be matched shape-wise against the training data.
  target_type
      Type of data: ``'X'`` | ``'Y'``. Used to determine if data should take the shape of predictor input or
      predictor output. ``'X'`` will utilize the `X_dims` attribute which stores the shape of the training data.
      ``'Y'`` will match the shape of `Y_dims` which is the shape of the target data.
  
  Raises
  ------
  ValueError
      If the shape of `data` does not match the shape of the training data, or fit has not been called prior to
      calling this method.
docstr_tok: ["Verify","the","shape","of","`","data","`","against","the","shape","of","the","training","data",".","Used","to","ensure","input","is","correct","shape","for","gradient","methods","implemented","in","the","backends",".","`","data","`","will","be","the","features","or","label","of","the","instance","being","explained",".","If","the","`","data","`","is","not","a","batch",",","reshape","to","be","a","single","batch","element",".","i.e",".","if","training","data","shape","is","`","(","3",",","28",",","28",")","`","and","data","shape","is","`","(","3",",","28",",","28",")","`","we","reshape","data","to","`","(","1",",","3",",","28",",","28",")","`",".","Parameters","--","--","--","--","--","data","Data","to","be","matched","shape-wise","against","the","training","data",".","target_type","Type","of","data",":","``","'","X","'","``","|","``","'","Y","'","``",".","Used","to","determine","if","data","should","take","the","shape","of","predictor","input","or","predictor","output",".","``","'","X","'","``","will","utilize","the","`","X_dims","`","attribute","which","stores","the","shape","of","the","training","data",".","``","'","Y","'","``","will","match","the","shape","of","`","Y_dims","`","which","is","the","shape","of","the","target","data",".","Raises","--","--","--","ValueError","If","the","shape","of","`","data","`","does","not","match","the","shape","of","the","training","data",",","or","fit","has","not","been","called","prior","to","calling","this","method","."]
code: def _match_shape_to_data(
      self,
      data: "Union[np.ndarray, tensorflow.Tensor, torch.Tensor, Any, List[Any]]",
      target_type: Literal["X", "Y"],
  ) -> "Union[np.ndarray, tensorflow.Tensor, torch.Tensor, List[Any]]":
      """
      Verify the shape of `data` against the shape of the training data.
  
      Used to ensure input is correct shape for gradient methods implemented in the backends. `data` will be the
      features or label of the instance being explained. If the `data` is not a batch, reshape to be a single batch
      element. i.e. if training data shape is `(3, 28, 28)` and data shape is `(3, 28, 28)` we reshape data to
      `(1, 3, 28, 28)`.
  
      Parameters
      ----------
      data
          Data to be matched shape-wise against the training data.
      target_type
          Type of data: ``'X'`` | ``'Y'``. Used to determine if data should take the shape of predictor input or
          predictor output. ``'X'`` will utilize the `X_dims` attribute which stores the shape of the training data.
          ``'Y'`` will match the shape of `Y_dims` which is the shape of the target data.
  
      Raises
      ------
      ValueError
          If the shape of `data` does not match the shape of the training data, or fit has not been called prior to
          calling this method.
      """
      if self._is_tensor(data):
          return self._match_shape_to_data_tensor(data, target_type)
      return self._match_shape_to_data_any(data)
  
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 6 for calling the BaseSimilarityExplainer obj's underlying member method code with example usage: obj._match_shape_to_data(data, target_type) and returns: self, self