code: def _validate_output(
      model: tf.keras.Model, target: Optional[np.ndarray]
  ) -> None:
      """
      Validates the model's output type and raises an error if the output type is not supported.
  
      Parameters
      ----------
      model
          `Keras` model for which the output is validated.
      target
          Targets for which gradients are calculated
      """
      if not model.output_shape or not any(
          isinstance(model.output_shape, t)
          for t in _valid_output_shape_type
      ):
          raise NotImplementedError(
              f"The model output_shape attribute must be in {_valid_output_shape_type}. "
              f"Found model.output_shape: {model.output_shape}"
          )
  
      if (
          len(model.output_shape) == 1 or model.output_shape[-1] == 1
      ) and target is None:
          logger.warning(
              "It looks like you are passing a model with a scalar output and target is set to `None`."
              "If your model is a regression model this will produce correct attributions. If your model "
              "is a classification model, targets for each datapoint must be defined. "
              "Not defining the target may lead to incorrect values for the attributions."
              "Targets can be either the true classes or the classes predicted by the model."
          )
  
imports: import copy
  import logging
  import string
  import warnings
  from enum import Enum
  from typing import Callable, List, Optional, Tuple, Union, cast
  import numpy
  import tensorflow
  from alibi.api.defaults import DEFAULT_DATA_INTGRAD, DEFAULT_META_INTGRAD
  from alibi.api.interfaces import Explainer, Explanation
  from alibi.utils.approximation_methods import approximation_parameters
label_desc: Use image node_id 15 for calling a global function with example usage: _validate_output(model, target) without return types