class_docstr: Base class for similarity explainers.
docstr: Verify the shape of `data` against the shape of the training data for tensor like data.
docstr_tok: ["Verify","the","shape","of","`","data","`","against","the","shape","of","the","training","data","for","tensor","like","data","."]
code: def _match_shape_to_data_tensor(
      self,
      data: "Union[np.ndarray, tensorflow.Tensor, torch.Tensor]",
      target_type: Literal["X", "Y"],
  ) -> "Union[np.ndarray, tensorflow.Tensor, torch.Tensor]":
      """Verify the shape of `data` against the shape of the training data for tensor like data."""
      target_shape = getattr(self, f"{target_type}_dims")
      if data.shape == target_shape:
          data = data[None]
      if data.shape[1:] != target_shape:
          raise ValueError(
              (
                  f"Input `{target_type}` has shape {data.shape[1:]}"
                  f" but training data has shape {target_shape}"
              )
          )
      return 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 7 for calling the BaseSimilarityExplainer obj's underlying member method code with example usage: obj._match_shape_to_data_tensor(data, target_type) and returns: data