code: def _check_target(
      output_shape: Tuple, target: Optional[np.ndarray], nb_samples: int
  ) -> None:
      """
      Parameters
      ----------
      output_shape
          Output shape of the tensorflow model
      target
          Target formatted as np array target.
      nb_samples
          Number of samples in the batch.
  
      Returns
      -------
      None
  
      """
  
      if target is not None:
          if not np.issubdtype(target.dtype, np.integer):
              raise ValueError("Targets must be integers")
  
          if target.shape[0] != nb_samples:
              raise ValueError(
                  f"First dimension in target must be the same as nb of samples. "
                  f"Found target first dimension: {target.shape[0]}; nb of samples: {nb_samples}"
              )
  
          if len(target.shape) > 2:
              raise ValueError(
                  "Target must be a rank-1 or a rank-2 tensor. If target is a rank-2 tensor, "
                  "each column contains the index of the corresponding dimension "
                  "in the model's output tensor."
              )
  
          if len(output_shape) == 1:
              # in case of squash output, the rank of the model's output tensor (out_rank) consider the batch dimension
              out_rank, target_rank = 1, len(target.shape)
              tmax, tmin = target.max(axis=0), target.min(axis=0)
  
              if tmax > 1:
                  raise ValueError(
                      f"Target value {tmax} out of range for output shape {output_shape} "
                  )
  
          # for all other cases, batch dimension is not considered in the out_rank
          elif len(output_shape) == 2:
              out_rank, target_rank = 1, len(target.shape)
              tmax, tmin = target.max(axis=0), target.min(axis=0)
  
              if (
                  output_shape[-1] > 1
                  and (tmax >= output_shape[-1]).any()
              ) or (output_shape[-1] == 1 and tmax > 1):
                  raise ValueError(
                      f"Target value {tmax} out of range for output shape {output_shape} "
                  )
  
          else:
              out_rank, target_rank = (
                  len(output_shape[1:]),
                  target.shape[-1],
              )
              tmax, tmin = target.max(axis=0), target.min(axis=0)
  
              if (tmax >= output_shape[1:]).any():
                  raise ValueError(
                      f"Target value {tmax} out of range for output shape {output_shape} "
                  )
  
          if (tmin < 0).any():
              raise ValueError(
                  f"Negative value {tmin} for target. Targets represent positional "
                  f"arguments and cannot be negative"
              )
  
          if out_rank != target_rank:
              raise ValueError(
                  f"The last dimension of target  must match the rank of the model's output tensor. "
                  f"Found target last dimension: {target_rank}; model's output rank: {out_rank}"
              )
  
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 11 for calling a global function with example usage: _check_target(output_shape, target, nb_samples) without return types