class_docstr: ConfusionMatrixAtK aggregate.
  
  Attributes:
    pos_label: the value considered as positive, default to 1.
    input_type: input encoding type, must be either  `multiclass` or
      `multiclass-multioutput`.
    average: average type, must be one of the types under `AverageType`.
    vocab: an external vocabulary that maps categorical value to integer class
      id. This is required if computed distributed (when merge_accumulators is
      called) and the average is macro where the class id mapping needs to be
      stable.
    k_list: a list of topk each of which slices y_pred by y_pred[:topk] assuming
      the predictions are sorted in descending order.
class_docstr_tok: ["ConfusionMatrixAtK","aggregate",".","Attributes",":","pos_label",":","the","value","considered","as","positive",",","default","to","1.","input_type",":","input","encoding","type",",","must","be","either","`","multiclass","`","or","`","multiclass-multioutput","`",".","average",":","average","type",",","must","be","one","of","the","types","under","`","AverageType","`",".","vocab",":","an","external","vocabulary","that","maps","categorical","value","to","integer","class","id",".","This","is","required","if","computed","distributed","(","when","merge_accumulators","is","called",")","and","the","average","is","macro","where","the","class","id","mapping","needs","to","be","stable",".","k_list",":","a","list","of","topk","each","of","which","slices","y_pred","by","y_pred","[",":","topk","]","assuming","the","predictions","are","sorted","in","descending","order","."]
code: def _calculate_confusion_matrix(
      self, y_true: _NumbersT, y_pred: _NumbersT
  ) -> _TopKConfusionMatrix:
      result = _topk_confusion_matrix(
          y_true,
          y_pred,
          k_list=self.k_list,
          vocab=self.vocab,
          multioutput=(
              self.input_type == InputType.MULTICLASS_MULTIOUTPUT
          ),
          average=AverageType(self.average),
      )
      return result
  
imports: from collections.abc import Iterable, Sequence
  import dataclasses
  import enum
  import itertools
  from typing import Any
  import numpy
  from numpy import typing
  from tensorflow_model_analysis.experimental.lazytf import api
label_desc: Use image node_id 2 for calling the TopKConfusionMatrixAggFn obj's underlying member method code with example usage: obj._calculate_confusion_matrix(y_true, y_pred) and returns: result