code: def _validate_doc(model, doc):
      # type: (Model, np.ndarray) -> None
      """
      Check that the input ``doc`` is suitable for ``model``.
      """
      if not isinstance(doc, np.ndarray):
          raise TypeError(
              "doc must be a numpy.ndarray, got: {}".format(doc)
          )
      input_sh = model.input_shape
      doc_sh = doc.shape
      if len(input_sh) == 4:
          # rank 4 with (batch, ...) shape
          # check that we have only one image (batch size 1)
          single_batch = (1,) + input_sh[1:]
          if doc_sh != single_batch:
              raise ValueError(
                  "Batch size does not match (must be 1). "
                  "doc must be of shape: {}, "
                  "got: {}".format(single_batch, doc_sh)
              )
      else:
          # other shapes
          if doc_sh != input_sh:
              raise ValueError(
                  "Input and doc shapes do not match."
                  "input: {}, doc: {}".format(input_sh, doc_sh)
              )
  
imports: from __future__ import absolute_import
  from typing import Union, Optional, Callable, Tuple, List, TYPE_CHECKING
  import numpy
  import keras
  import keras.backend
  from keras.models import Model
  from keras.layers import Layer
  from keras.layers import Conv2D, MaxPooling2D, AveragePooling2D, GlobalMaxPooling2D, GlobalAveragePooling2D
  from keras.preprocessing.image import array_to_img
  from eli5.base import Explanation, TargetExplanation
  from eli5.explain import explain_prediction
  from .gradcam import gradcam, gradcam_backend
label_desc: Use image node_id 9 for calling a global function with example usage: _validate_doc(model, doc) without return types