class_docstr: Implements matrix scaling of logits, as described in Beyond temperature scaling: Obtaining well-calibrated
  multiclass probabilities with Dirichlet calibration https://arxiv.org/abs/1910.12656.
  
  Unlike temperature scaling which has only one free parameter, matrix scaling has n_classes x (n_classes + 1)
  parameters. Use this only with a large validation set, as matrix scaling has a tendency to overfit small datasets.
  Also, unlike temperature scaling, matrix scaling can change the argmax or top-n predictions.
  
  NOTE: Matrix Scaling is not exposed in the UI or config yet, though it may be in a future release after testing.
  
  Args:
  num_classes: The number of classes.
  off_diagonal_l2: The regularization weight for off-diagonal matrix entries.
  mu: The regularization weight for bias vector. Defaults to off_diagonal_l2 if not specified.
class_docstr_tok: ["Implements","matrix","scaling","of","logits",",","as","described","in","Beyond","temperature","scaling",":","Obtaining","well-calibrated","multiclass","probabilities","with","Dirichlet","calibration","https",":","\/\/arxiv.org\/abs\/1910.12656",".","Unlike","temperature","scaling","which","has","only","one","free","parameter",",","matrix","scaling","has","n_classes","x","(","n_classes","+","1",")","parameters",".","Use","this","only","with","a","large","validation","set",",","as","matrix","scaling","has","a","tendency","to","overfit","small","datasets",".","Also",",","unlike","temperature","scaling",",","matrix","scaling","can","change","the","argmax","or","top-n","predictions",".","NOTE",":","Matrix","Scaling","is","not","exposed","in","the","UI","or","config","yet",",","though","it","may","be","in","a","future","release","after","testing",".","Args",":","num_classes",":","The","number","of","classes",".","off_diagonal_l2",":","The","regularization","weight","for","off-diagonal","matrix","entries",".","mu",":","The","regularization","weight","for","bias","vector",".","Defaults","to","off_diagonal_l2","if","not","specified","."]
code: def scale_logits(self, logits: torch.Tensor) -> torch.Tensor:
      return torch.matmul(self.w, logits.T).T + self.b
  
imports: import logging
  from abc import ABC, abstractmethod
  from dataclasses import dataclass
  from typing import List, Type, Union
  import numpy
  import torch
  import torch.nn
  from ludwig.api_annotations import DeveloperAPI
  from ludwig.constants import BINARY, CATEGORY
  from ludwig.utils.registry import DEFAULT_KEYS, Registry
label_desc: Use image node_id 4 for calling the MatrixScaling obj's underlying member method code with example usage: obj.scale_logits(logits) and returns: unknown