code: def sanitize_array(array: np.ndarray) -> np.ndarray:
      """
      Replace NaN and Inf (there should not be any!)
      :param array:
      :return:
      """
      a = np.ravel(array)
      maxi = np.nanmax(a[np.isfinite(a)])
      mini = np.nanmin(a[np.isfinite(a)])
      array[array == float("inf")] = maxi
      array[array == float("-inf")] = mini
      mid = (maxi + mini) / 2
      array[np.isnan(array)] = mid
      return array
  
label_desc: Use image node_id 1 for calling a global function with example usage: sanitize_array(array) and returns: array