code: def _compute_expected_freqs(confmat: Tensor) -> Tensor:
      """Compute the expected frequenceis from the provided confusion matrix."""
      margin_sum_rows, margin_sum_cols = confmat.sum(1), confmat.sum(0)
      return (
          torch.einsum("r, c -> rc", margin_sum_rows, margin_sum_cols)
          / confmat.sum()
      )
  
file_path: torchmetrics/src/torchmetrics/functional/nominal/utils.py
imports: from typing import Optional, Tuple
  import torch
  from torch import Tensor
  from typing_extensions import Literal
  from torchmetrics.utilities.prints import rank_zero_warn
label_desc: Use image node_id 2 for calling a global function with example usage: _compute_expected_freqs(confmat) and returns: unknown