code: def test_get_diagonal_subtensor_view(wrap=lambda a: a):
      x = np.arange(20).reshape(5, 4).astype("float32")
      x = wrap(x)
      xv01 = get_diagonal_subtensor_view(x, 0, 1)
  
      # test that it works in 2d
      assert np.all(
          np.asarray(xv01) == [[12, 9, 6, 3], [16, 13, 10, 7]]
      )
  
      x = np.arange(24).reshape(4, 3, 2)
      xv01 = get_diagonal_subtensor_view(x, 0, 1)
      xv02 = get_diagonal_subtensor_view(x, 0, 2)
      xv12 = get_diagonal_subtensor_view(x, 1, 2)
  
      # print 'x', x
      # print 'xv01', xv01
      # print 'xv02', xv02
      assert np.all(
          np.asarray(xv01)
          == [
              [[12, 13], [8, 9], [4, 5]],
              [[18, 19], [14, 15], [10, 11]],
          ]
      )
  
      assert np.all(
          np.asarray(xv02)
          == [
              [[6, 1], [8, 3], [10, 5]],
              [[12, 7], [14, 9], [16, 11]],
              [[18, 13], [20, 15], [22, 17]],
          ]
      )
  
      # diagonal views of each leading matrix is the same
      # as the slices out of the diagonal view of the entire 3d tensor
      for xi, xvi in zip(x, xv12):
          assert np.all(xvi == get_diagonal_subtensor_view(xi, 0, 1))
  
file_path: Theano/theano/tensor/nnet/tests/test_conv3d2d.py
imports: from __future__ import absolute_import, print_function, division
  import time
  from nose.plugins.skip import SkipTest
  from parameterized import parameterized
  import numpy
  from six.moves import xrange
  import theano
  from theano.gof.opt import check_stack_trace
  from theano.tensor.nnet.conv3d2d import conv3d, get_diagonal_subtensor_view, DiagonalSubtensor, IncDiagonalSubtensor
  import theano.tests.unittest_tools
label_desc: Use image node_id 1 for calling a global function with example usage: test_get_diagonal_subtensor_view(wrap) without return types