code: def test_DiagonalOf():
      x = MatrixSymbol("x", n, n)
      d = DiagonalOf(x)
      assert d.shape == (n, 1)
      assert d.diagonal_length == n
      assert d[2, 0] == d[2] == x[2, 2]
  
      x = MatrixSymbol("x", n, m)
      d = DiagonalOf(x)
      assert d.shape == (None, 1)
      assert d.diagonal_length is None
      assert d[2, 0] == d[2] == x[2, 2]
  
      d = DiagonalOf(MatrixSymbol("x", 4, 3))
      assert d.shape == (3, 1)
      d = DiagonalOf(MatrixSymbol("x", n, 3))
      assert d.shape == (3, 1)
      d = DiagonalOf(MatrixSymbol("x", 3, n))
      assert d.shape == (3, 1)
      x = MatrixSymbol("x", n, m)
      assert [DiagonalOf(x)[i] for i in range(4)] == [
          x[0, 0],
          x[1, 1],
          x[2, 2],
          x[3, 3],
      ]
  
file_path: sympy/sympy/matrices/expressions/tests/test_diagonal.py
imports: from sympy.matrices.expressions import MatrixSymbol
  from sympy.matrices.expressions.diagonal import DiagonalMatrix, DiagonalOf, DiagMatrix, diagonalize_vector
  from sympy.assumptions.ask import Q, ask
  from sympy.core.symbol import Symbol
  from sympy.functions.special.tensor_functions import KroneckerDelta
  from sympy.matrices.dense import Matrix
  from sympy.matrices.expressions.matmul import MatMul
  from sympy.matrices.expressions.special import Identity
  from sympy.testing.pytest import raises
label_desc: Use image node_id 2 for calling a global function with example usage: test_DiagonalOf() without return types