class_docstr: Computes Multi-label confusion matrix.
  
  Class-wise confusion matrix is computed for the
  evaluation of classification.
  
  If multi-class input is provided, it will be treated
  as multilabel data.
  
  Consider classification problem with two classes
  (i.e num_classes=2).
  
  Resultant matrix `M` will be in the shape of `(num_classes, 2, 2)`.
  
  Every class `i` has a dedicated matrix of shape `(2, 2)` that contains:
  
  - true negatives for class `i` in `M(0,0)`
  - false positives for class `i` in `M(0,1)`
  - false negatives for class `i` in `M(1,0)`
  - true positives for class `i` in `M(1,1)`
  
  Args:
      num_classes: `int`, the number of labels the prediction task can have.
      name: (Optional) string name of the metric instance.
      dtype: (Optional) data type of the metric result.
  
  Usage:
  
  >>> # multilabel confusion matrix
  >>> y_true = np.array([[1, 0, 1], [0, 1, 0]], dtype=np.int32)
  >>> y_pred = np.array([[1, 0, 0], [0, 1, 1]], dtype=np.int32)
  >>> metric = tfa.metrics.MultiLabelConfusionMatrix(num_classes=3)
  >>> metric.update_state(y_true, y_pred)
  >>> result = metric.result()
  >>> result.numpy()  #doctest: -DONT_ACCEPT_BLANKLINE
  array([[[1., 0.],
          [0., 1.]],
  <BLANKLINE>
         [[1., 0.],
          [0., 1.]],
  <BLANKLINE>
         [[0., 1.],
          [1., 0.]]], dtype=float32)
  >>> # if multiclass input is provided
  >>> y_true = np.array([[1, 0, 0], [0, 1, 0]], dtype=np.int32)
  >>> y_pred = np.array([[1, 0, 0], [0, 0, 1]], dtype=np.int32)
  >>> metric = tfa.metrics.MultiLabelConfusionMatrix(num_classes=3)
  >>> metric.update_state(y_true, y_pred)
  >>> result = metric.result()
  >>> result.numpy() #doctest: -DONT_ACCEPT_BLANKLINE
  array([[[1., 0.],
          [0., 1.]],
  <BLANKLINE>
         [[1., 0.],
          [1., 0.]],
  <BLANKLINE>
         [[1., 1.],
          [0., 0.]]], dtype=float32)
class_docstr_tok: ["Computes","Multi-label","confusion","matrix",".","Class-wise","confusion","matrix","is","computed","for","the","evaluation","of","classification",".","If","multi-class","input","is","provided",",","it","will","be","treated","as","multilabel","data",".","Consider","classification","problem","with","two","classes","(","i.e","num_classes=2",")",".","Resultant","matrix","`","M","`","will","be","in","the","shape","of","`","(","num_classes",",","2",",","2",")","`",".","Every","class","`","i","`","has","a","dedicated","matrix","of","shape","`","(","2",",","2",")","`","that","contains",":","-","true","negatives","for","class","`","i","`","in","`","M","(","0,0",")","`","-","false","positives","for","class","`","i","`","in","`","M","(","0,1",")","`","-","false","negatives","for","class","`","i","`","in","`","M","(","1,0",")","`","-","true","positives","for","class","`","i","`","in","`","M","(","1,1",")","`","Args",":","num_classes",":","`","int","`",",","the","number","of","labels","the","prediction","task","can","have",".","name",":","(","Optional",")","string","name","of","the","metric","instance",".","dtype",":","(","Optional",")","data","type","of","the","metric","result",".","Usage",":",">",">",">","#","multilabel","confusion","matrix",">",">",">","y_true","=","np.array","(","[","[","1",",","0",",","1","]",",","[","0",",","1",",","0","]","]",",","dtype=np.int32",")",">",">",">","y_pred","=","np.array","(","[","[","1",",","0",",","0","]",",","[","0",",","1",",","1","]","]",",","dtype=np.int32",")",">",">",">","metric","=","tfa.metrics.MultiLabelConfusionMatrix","(","num_classes=3",")",">",">",">","metric.update_state","(","y_true",",","y_pred",")",">",">",">","result","=","metric.result","(",")",">",">",">","result.numpy","(",")","#","doctest",":","-DONT_ACCEPT_BLANKLINE","array","(","[","[","[","1.",",","0",".","]",",","[","0.",",","1",".","]","]",",","<","BLANKLINE",">","[","[","1.",",","0",".","]",",","[","0.",",","1",".","]","]",",","<","BLANKLINE",">","[","[","0.",",","1",".","]",",","[","1.",",","0",".","]","]","]",",","dtype=float32",")",">",">",">","#","if","multiclass","input","is","provided",">",">",">","y_true","=","np.array","(","[","[","1",",","0",",","0","]",",","[","0",",","1",",","0","]","]",",","dtype=np.int32",")",">",">",">","y_pred","=","np.array","(","[","[","1",",","0",",","0","]",",","[","0",",","0",",","1","]","]",",","dtype=np.int32",")",">",">",">","metric","=","tfa.metrics.MultiLabelConfusionMatrix","(","num_classes=3",")",">",">",">","metric.update_state","(","y_true",",","y_pred",")",">",">",">","result","=","metric.result","(",")",">",">",">","result.numpy","(",")","#","doctest",":","-DONT_ACCEPT_BLANKLINE","array","(","[","[","[","1.",",","0",".","]",",","[","0.",",","1",".","]","]",",","<","BLANKLINE",">","[","[","1.",",","0",".","]",",","[","1.",",","0",".","]","]",",","<","BLANKLINE",">","[","[","1.",",","1",".","]",",","[","0.",",","0",".","]","]","]",",","dtype=float32",")"]
code: def result(self):
      flat_confusion_matrix = tf.convert_to_tensor(
          [
              self.true_negatives,
              self.false_positives,
              self.false_negatives,
              self.true_positives,
          ]
      )
      # reshape into 2*2 matrix
      confusion_matrix = tf.reshape(
          tf.transpose(flat_confusion_matrix), [-1, 2, 2]
      )
  
      return confusion_matrix
  
file_path: addons/tensorflow_addons/metrics/multilabel_confusion_matrix.py
imports: import warnings
  import tensorflow
  from tensorflow.keras import backend
  from tensorflow.keras.metrics import Metric
  import numpy
  from typeguard import typechecked
  from tensorflow_addons.utils.types import AcceptableDTypes, FloatTensorLike
label_desc: Use image node_id 3 for calling the MultiLabelConfusionMatrix obj's underlying member method code with example usage: obj.result() and returns: confusion_matrix