code: def add_metric(self, output1, output2):
      self._total_count += 1
      if self._topk == 1:
          if output1 == output2:
              self._correct_count += 1
      else:
          self._topk = min(len(output1.keys()), self._topk)
          out1_topk = sorted(output1, key=output1.get, reverse=True)[
              : self._topk
          ]
          out2_topk = sorted(output2, key=output2.get, reverse=True)[
              : self._topk
          ]
          if out1_topk[0] in out2_topk:
              self._correct_count += 1
  
imports: from __future__ import print_function
  from __future__ import division
  from __future__ import absolute_import
  import numpy
  from sys import stdout
  from os import listdir
  from six import string_types
  from .optimization_utils import _optimize_nn
  from coremltools.models import _SUPPORTED_QUANTIZATION_MODES, _QUANTIZATION_MODE_DEQUANTIZE, _QUANTIZATION_MODE_LOOKUP_TABLE_LINEAR, _QUANTIZATION_MODE_LOOKUP_TABLE_KMEANS, _QUANTIZATION_MODE_CUSTOM_LOOKUP_TABLE, _QUANTIZATION_MODE_LINEAR_QUANTIZATION, _QUANTIZATION_MODE_LINEAR_SYMMETRIC, _LUT_BASED_QUANTIZATION
  from ..utils import _get_nn_layers, _wp_to_fp16wp, _get_model, _macos_version
  from ..._deps import _HAS_SKLEARN
  from ...None import _MINIMUM_QUANTIZED_MODEL_SPEC_VERSION, _MINIMUM_FP16_SPEC_VERSION, _SPECIFICATION_VERSION_IOS_14
label_desc: Use image node_id 2 for calling the TopKMetrics obj's underlying member method code with example usage: obj.add_metric(output1, output2) without return types