code: def _multiclass_confusion_matrix(
      y_true: _NumbersT,
      y_pred: _NumbersT,
      *,
      vocab: dict[str, int] | None = None,
      multioutput: bool = False,
      average: AverageType = AverageType.MICRO,
  ) -> _ConfusionMatrix:
      """Calculates a confusion matrix for multiclass(-multioutput) input.
  
      Args:
        y_true: ground truth classification labels. This has to be encoded in one of
          the `multiclass` or `multiclass-output`.
        y_pred: classification preditions. This has to be encoded in one of the
          `multiclass` or `multiclass-output`.
        vocab: an external vocabulary that maps categorical value to integer class
          id. If not provided, one is deduced within this input.
        multioutput: encoding types of the y_true and y_pred, if True, the input is
          a nested list of class identifiers.
        average: average type of the confusion matrix.
  
      Returns:
        Confusion matrices with k in k_list.
      """
      vocab = vocab or _get_vocab(
          itertools.chain(y_true, y_pred), multioutput
      )
      y_true_dense = _apply_vocab(y_true, vocab, multioutput)
      y_pred_dense = _apply_vocab(y_pred, vocab, multioutput)
      return _indicator_confusion_matrix(
          y_true_dense,
          y_pred_dense,
          average=average,
          multiclass=True,
          pos_label=True,
      )
  
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 9 for calling a global function with example usage: _multiclass_confusion_matrix(y_true, y_pred) and returns: _indicator_confusion_matrix