code: def compute_accuracy(
      preds: np.ndarray, labels: np.ndarray, abstain: bool = True
  ) -> Tuple[float, float]:
      """
      Compute the accuracy rate and coverage rate of predictions
      In the case where predictions are abstained, those samples are ignored.
  
      :param preds: Predictions.
      :param labels: Correct labels of `x`.
      :param abstain: True if ignore abstained prediction, False if count them as incorrect.
      :return: Tuple of accuracy rate and coverage rate.
      """
      has_pred = np.sum(preds, axis=1)
      idx_pred = np.where(has_pred)[0]
      labels = np.argmax(labels[idx_pred], axis=1)
      num_correct = np.sum(np.argmax(preds[idx_pred], axis=1) == labels)
      coverage_rate = len(idx_pred) / preds.shape[0]
  
      if abstain:
          acc_rate = num_correct / preds[idx_pred].shape[0]
      else:
          acc_rate = num_correct / preds.shape[0]
  
      return acc_rate, coverage_rate
  
imports: from __future__ import absolute_import, division, print_function, unicode_literals
  import logging
  import math
  import os
  import shutil
  import sys
  import tarfile
  import warnings
  import zipfile
  from functools import wraps
  from inspect import signature
  from typing import TYPE_CHECKING, Callable, List, Dict, Optional, Tuple, Union
  import numpy
  import six
  from scipy.special import gammainc
  from tqdm.auto import tqdm
  from art import config
label_desc: Use image node_id 24 for calling a global function with example usage: compute_accuracy(preds, labels, abstain) and returns: acc_rate,  coverage_rate