code: def _compute_convergence_delta(
      model: Union[tf.keras.models.Model],
      input_dtypes: List[tf.DType],
      attributions: List[np.ndarray],
      start_point: Union[List[np.ndarray], np.ndarray],
      end_point: Union[List[np.ndarray], np.ndarray],
      forward_kwargs: Optional[dict],
      target: Optional[np.ndarray],
      _is_list: bool,
  ) -> np.ndarray:
      """
      Computes convergence deltas for each data point. Convergence delta measures how close the sum of all attributions
      is to the difference between the model output at the baseline and the model output at the data point.
  
      Parameters
      ----------
      model
          `tensorflow` model.
      input_dtypes
          List with data types of the inputs.
      attributions
          Attributions assigned by the integrated gradients method to each feature.
      start_point
          Baselines.
      end_point
          Data points.
      forward_kwargs
          Input keywords args.
      target
          Target for which the gradients are calculated for classification models.
      _is_list
          Whether the model's input is a `list` (multiple inputs) or a `np.narray` (single input).
  
      Returns
      -------
      Convergence deltas for each data point.
      """
      if forward_kwargs is None:
          forward_kwargs = {}
      if _is_list:
          start_point = [
              tf.convert_to_tensor(
                  start_point[k], dtype=input_dtypes[k]
              )
              for k in range(len(input_dtypes))
          ]
          end_point = [
              tf.convert_to_tensor(end_point[k], dtype=input_dtypes[k])
              for k in range(len(input_dtypes))
          ]
      else:
          start_point = tf.convert_to_tensor(start_point)
          end_point = tf.convert_to_tensor(end_point)
  
      def _sum_rows(inp):
          input_str = string.ascii_lowercase[1 : len(inp.shape)]
          if isinstance(inp, tf.Tensor):
              sums = tf.einsum("a{}->a".format(input_str), inp).numpy()
          elif isinstance(inp, np.ndarray):
              sums = np.einsum("a{}->a".format(input_str), inp)
          else:
              raise NotImplementedError(
                  "input must be a tensorflow tensor or a numpy array"
              )
          return sums
  
      start_out = _run_forward(
          model, start_point, target, forward_kwargs=forward_kwargs
      )
      end_out = _run_forward(
          model, end_point, target, forward_kwargs=forward_kwargs
      )
  
      if (
          len(model.output_shape) == 1 or model.output_shape[-1] == 1
      ) and target is not None:
          target_tensor = tf.cast(target, dtype=start_out.dtype)
          target_tensor = tf.reshape(
              1 - target_tensor, [len(target), 1]
          )
          sign = 2 * target_tensor - 1
  
          start_out = target_tensor + sign * start_out
          end_out = target_tensor + sign * end_out
  
      start_out_sum = _sum_rows(start_out)
      end_out_sum = _sum_rows(end_out)
  
      attr_sum = np.zeros(start_out_sum.shape)
      for j in range(len(attributions)):
          attrs_sum_j = _sum_rows(attributions[j])
          attr_sum += attrs_sum_j
  
      _deltas = attr_sum - (end_out_sum - start_out_sum)
  
      return _deltas
  
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 1 for calling a global function with example usage: _compute_convergence_delta(model, input_dtypes, attributions, start_point, end_point, forward_kwargs, target, _is_list) and returns: _deltas, sums