code: def test_ndarray_diagonal():
      assert np.array_equal(
          hl.eval(hl.nd.diagonal(hl.nd.array([[1, 2], [3, 4]]))),
          np.array([1, 4]),
      )
      assert np.array_equal(
          hl.eval(hl.nd.diagonal(hl.nd.array([[1, 2, 3], [4, 5, 6]]))),
          np.array([1, 5]),
      )
      assert np.array_equal(
          hl.eval(
              hl.nd.diagonal(hl.nd.array([[1, 2], [3, 4], [5, 6]]))
          ),
          np.array([1, 4]),
      )
  
      with pytest.raises(AssertionError) as exc:
          hl.nd.diagonal(hl.nd.array([1, 2]))
      assert "2 dimensional" in str(exc.value)
  
imports: import math
  import numpy
  import re
  from ..helpers import *
  import pytest
  from hail.utils.java import FatalError, HailUserError
label_desc: Use image node_id 22 for calling a global function with example usage: test_ndarray_diagonal() without return types