code: def get_input_shape(
      shape: Optional[Tuple], x_ref: Union[np.ndarray, list]
  ) -> Optional[Tuple]:
      """Optionally infer shape from reference data."""
      if isinstance(shape, tuple):
          return shape
      elif hasattr(x_ref, "shape"):
          return x_ref.shape[1:]
      else:
          logger.warning(
              "Input shape could not be inferred. "
              "If alibi_detect.models.tensorflow.embedding.TransformerEmbedding "
              "is used as preprocessing step, a saved detector cannot be reinitialized."
          )
          return None
  
file_path: alibi-detect/alibi_detect/cd/utils.py
imports: import logging
  import random
  from typing import Callable, Dict, Optional, Tuple, Union
  import numpy
  from alibi_detect.utils.sampling import reservoir_sampling
  from alibi_detect.utils.frameworks import Framework
  from alibi_detect.utils._types import TorchDeviceType
label_desc: Use image node_id 4 for calling a global function with example usage: get_input_shape(shape, x_ref) and returns: shape, x_ref, None