class_docstr: Class for the space of matrices (m, n).
  
  Parameters
  ----------
  m, n : int
      Integers representing the shapes of the matrices: m x n.
class_docstr_tok: ["Class","for","the","space","of","matrices","(","m",",","n",")",".","Parameters","--","--","--","--","--","m",",","n",":","int","Integers","representing","the","shapes","of","the","matrices",":","m","x","n","."]
docstr: Return the diagonal of a matrix as a vector.
  
  Parameters
  ----------
  mat : array-like, shape=[..., m, n]
      Matrix.
  
  Returns
  -------
  diagonal : array-like, shape=[..., min(m, n)]
      Vector of diagonal coefficients.
docstr_tok: ["Return","the","diagonal","of","a","matrix","as","a","vector",".","Parameters","--","--","--","--","--","mat",":","array-like",",","shape=","[","...",",","m",",","n","]","Matrix",".","Returns","--","--","--","-","diagonal",":","array-like",",","shape=","[","...",",","min","(","m",",","n",")","]","Vector","of","diagonal","coefficients","."]
code: def diagonal(mat):
      """Return the diagonal of a matrix as a vector.
  
      Parameters
      ----------
      mat : array-like, shape=[..., m, n]
          Matrix.
  
      Returns
      -------
      diagonal : array-like, shape=[..., min(m, n)]
          Vector of diagonal coefficients.
      """
      return gs.diagonal(mat, axis1=-2, axis2=-1)
  
imports: import logging
  import math
  from functools import reduce
  import geomstats.backend
  import geomstats.errors
  from geomstats.algebra_utils import flip_determinant, from_vector_to_diagonal_matrix
  from geomstats.geometry.base import MatrixVectorSpace
  from geomstats.geometry.euclidean import EuclideanMetric
  from geomstats.vectorization import repeat_out
label_desc: Use image node_id 9 for calling the Matrices obj's underlying member method code with example usage: obj.diagonal(mat) and returns: gs