code: def test_gpu_tril_triu():
      def check_l(m, k=0):
          m_symb = T.matrix(dtype=m.dtype)
          k_symb = T.iscalar()
  
          f = theano.function(
              [m_symb, k_symb],
              T.tril(m_symb, k_symb),
              mode=mode_with_gpu,
          )
          result = f(m, k)
          assert np.allclose(result, np.tril(m, k))
          assert result.dtype == np.dtype(dtype)
          assert any(
              [
                  isinstance(node.op, GpuTri)
                  for node in f.maker.fgraph.toposort()
              ]
          )
  
      def check_u(m, k=0):
          m_symb = T.matrix(dtype=m.dtype)
          k_symb = T.iscalar()
          f = theano.function(
              [m_symb, k_symb],
              T.triu(m_symb, k_symb),
              mode=mode_with_gpu,
          )
          result = f(m, k)
          assert np.allclose(result, np.triu(m, k))
          assert result.dtype == np.dtype(dtype)
          assert any(
              [
                  isinstance(node.op, GpuTri)
                  for node in f.maker.fgraph.toposort()
              ]
          )
  
      utt.seed_rng()
      test_rng = np.random.RandomState(seed=utt.fetch_seed())
  
      for dtype in ["float64", "float32", "float16"]:
          # try a big one
          m = np.asarray(test_rng.rand(5000, 5000) * 2 - 1, dtype=dtype)
          yield check_l, m, 0
          yield check_l, m, 1
          yield check_l, m, -1
  
          yield check_u, m, 0
          yield check_u, m, 1
          yield check_u, m, -1
  
          m = np.asarray(test_rng.rand(10, 10) * 2 - 1, dtype=dtype)
          yield check_l, m, 0
          yield check_l, m, 1
          yield check_l, m, -1
  
          yield check_u, m, 0
          yield check_u, m, 1
          yield check_u, m, -1
  
          m = np.asarray(test_rng.rand(10, 5) * 2 - 1, dtype=dtype)
          yield check_l, m, 0
          yield check_l, m, 1
          yield check_l, m, -1
  
          yield check_u, m, 0
          yield check_u, m, 1
          yield check_u, m, -1
  
imports: from __future__ import absolute_import, print_function, division
  import unittest
  from theano.compat import izip
  from six import iteritems
  import numpy
  import theano
  import theano.tensor
  from theano.tensor import TensorType
  from theano.tensor.basic import alloc
  from theano.tensor.tests import test_basic
  from theano.tensor.tests.test_basic import rand, safe_make_node
  from theano.tests import unittest_tools
  from ..type import GpuArrayType, get_context, gpuarray_shared_constructor
  from ..basic_ops import host_from_gpu, HostFromGpu, GpuFromHost, GpuReshape, GpuToGpu, GpuAlloc, GpuAllocEmpty, GpuContiguous, gpu_join, GpuJoin, GpuSplit, GpuEye, GpuTri, gpu_contiguous
  from ..elemwise import GpuDimShuffle, GpuElemwise
  from ..subtensor import GpuSubtensor
  from .config import mode_with_gpu, mode_without_gpu, test_ctx_name
  from pygpu import gpuarray
label_desc: Use image node_id 16 for calling a global function with example usage: test_gpu_tril_triu() without return types