code: def _compute_mat_trace(
      input: torch.Tensor, dim1: int = -1, dim2: int = -2
  ) -> torch.Tensor:
      r"""Compute the trace of a Tensor along ``dim1`` and ``dim2`` dimensions.
  
      Args:
          input (torch.Tensor): Tensor with dimensions `(..., channel, channel)`.
          dim1 (int, optional): The first dimension of the diagonal matrix.
              (Default: ``-1``)
          dim2 (int, optional): The second dimension of the diagonal matrix.
              (Default: ``-2``)
  
      Returns:
          Tensor: The trace of the input Tensor.
      """
      if input.ndim < 2:
          raise ValueError(
              "The dimension of the tensor must be at least 2."
          )
      if input.shape[dim1] != input.shape[dim2]:
          raise ValueError(
              "The size of ``dim1`` and ``dim2`` must be the same."
          )
      input = torch.diagonal(input, 0, dim1=dim1, dim2=dim2)
      return input.sum(dim=-1)
  
imports: import math
  import tempfile
  import warnings
  from collections.abc import Sequence
  from typing import List, Optional, Tuple, Union
  import torch
  import torchaudio
  from torch import Tensor
  from torchaudio._internal.module_utils import deprecated
  from .filtering import highpass_biquad, treble_biquad
label_desc: Use image node_id 39 for calling a global function with example usage: _compute_mat_trace(input, dim1, dim2) and returns: input