class_docstr: TopK sample mean aggregate.
  
  Attributes:
    k_list: topk list used to truncate prediction. E.g., in an retrieval results
      of ['dog', 'cat', 'pig'], k=[2] means only ['dog', 'cat'] is used as the
      prediction. The default is None, which means all outputs in each
      prediction is included. Effectively k=None is same as k=[inf].
    metrics: The metrics to be computed.
    input_type: input encoding type, must be multiclass(-multioutput).
docstr: Extract the metric results from the intermediate states.
docstr_tok: ["Extract","the","metric","results","from","the","intermediate","states","."]
code: def extract_output(self, states: _SamplewiseMeanAggFnState) -> Any:
      """Extract the metric results from the intermediate states."""
      result = [states[metric].result() for metric in self.metrics]
      # Extends the remaining Ks from the last value.
  
      if self.k_list and result and len(self.k_list) > len(result[0]):
          for i, metric_result in enumerate(result):
              extra_ks = len(self.k_list) - len(metric_result)
              result[i] = (
                  list(metric_result) + [metric_result[-1]] * extra_ks
              )
      return tuple(tuple(metric) for metric in result)
  
imports: from collections.abc import Sequence
  import dataclasses
  from typing import Any
  import numpy
  from numpy import typing
  from tensorflow_model_analysis.experimental.lazytf import api
  from tensorflow_model_analysis.experimental.metrics.aggregates import _classification
label_desc: Use image node_id 6 for calling the TopKSamplewiseMeanAggFn obj's underlying member method code with example usage: obj.extract_output(states) and returns: tuple