code: def _evaluate_top_k(ytrue, ypred, logits, k, targets_map):
      confs = []
      correct = []
      for idx, (_ytrue, _logits) in enumerate(zip(ytrue, logits)):
          if _logits is None:
              # No logits; no prediction
              ypred[idx] = None
              _conf = None
              _correct = False
              msg = (
                  "Found sample(s) with no logits. Logits are required to "
                  + "compute top-k accuracy"
              )
              warnings.warn(msg)
          elif _ytrue is None:
              # Missing ground truth
              _correct = ypred[idx] is None
              _conf = None
          else:
              try:
                  target = targets_map[_ytrue]
              except KeyError:
                  raise ValueError(
                      "Found ground truth label '%s' not in provided classes"
                      % _ytrue
                  )
  
              if k >= len(_logits):
                  found = True
              else:
                  top_k = np.argpartition(_logits, -k)[-k:]
                  found = target in top_k
  
              if found:
                  # Truth is in top-k; use it
                  ypred[idx] = _ytrue
                  logit = _logits[target]
                  _correct = True
              elif ypred[idx] is not None:
                  # Truth is not in top-k; retain actual prediction
                  _ypred = ypred[idx]
  
                  try:
                      _pred_idx = targets_map[_ypred]
                  except KeyError:
                      raise ValueError(
                          "Found predicted label '%s' not in provided classes"
                          % _ypred
                      )
  
                  logit = _logits[_pred_idx]
                  _correct = False
              else:
                  # Missing prediction
                  logit = -np.inf
                  _correct = False
  
              _conf = np.exp(logit) / np.sum(np.exp(_logits))
  
          confs.append(_conf)
          correct.append(_correct)
  
      return confs, correct
  
imports: from copy import deepcopy
  import inspect
  import itertools
  import warnings
  import numpy
  import sklearn.metrics
  import eta.core.utils
  import fiftyone
  import fiftyone.core.evaluation
  from fiftyone.core.expressions import ViewField
  import fiftyone.core.fields
  import fiftyone.core.labels
  import fiftyone.core.plots
  import fiftyone.core.utils
  import fiftyone.core.validation
  from .base import BaseEvaluationResults
label_desc: Use image node_id 2 for calling a global function with example usage: _evaluate_top_k(ytrue, ypred, logits, k, targets_map) and returns: confs,  correct