code: def test_matrix(self, vals=None):
      if vals is None:
          vals = (100 * get_mat(5) + 1).astype("l")
      b = zeros((5,))
      for k in range(5):
          b[k] = vals[k, k]
      assert_equal(diag(vals), b)
      b = b * 0
      for k in range(3):
          b[k] = vals[k, k + 2]
      assert_equal(diag(vals, 2), b[:3])
      for k in range(3):
          b[k] = vals[k + 2, k]
      assert_equal(diag(vals, -2), b[:3])
  
imports: from numpy.testing import assert_equal, assert_array_equal, assert_array_max_ulp, assert_array_almost_equal, assert_raises, assert_
  from numpy import arange, add, fliplr, flipud, zeros, ones, eye, array, diag, histogram2d, tri, mask_indices, triu_indices, triu_indices_from, tril_indices, tril_indices_from, vander
  import numpy
  import pytest
label_desc: Use image node_id 2 for calling the TestDiag obj's underlying member method code with example usage: obj.test_matrix(vals) without return types