code: def test_memory(self):
      # Test that scan_checkpoint reduces memory usage.
      if None not in theano.gpuarray.type.list_contexts():
          return unittest.SkipTest("Requires gpuarray backend.")
      from theano.gpuarray.tests.config import mode_with_gpu  # noqa
  
      f = theano.function(
          inputs=[self.A, self.k],
          outputs=self.grad_A,
          mode=mode_with_gpu,
      )
      f_check = theano.function(
          inputs=[self.A, self.k],
          outputs=self.grad_A_check,
          mode=mode_with_gpu,
      )
      free_gmem = theano.gpuarray.type._context_reg[None].free_gmem
      data = np.ones(free_gmem // 3000, dtype=np.float32)
      # Check that it works with the checkpoints
      size = 1000
      if isinstance(mode_with_gpu, theano.compile.DebugMode):
          size = 100
      f_check(data, size)
      # Check that the basic scan fails in that case
      # Skip that check in DebugMode, as it can fail in different ways
      if not isinstance(mode_with_gpu, theano.compile.DebugMode):
          self.assertRaises(GpuArrayException, f, data, 1000)
  
file_path: Theano/theano/scan_module/tests/test_scan_checkpoints.py
imports: from __future__ import absolute_import, print_function, division
  import numpy
  import unittest
  import theano
  import theano.tensor
label_desc: Use image node_id 4 for calling the TestScanCheckpoint obj's underlying member method code with example usage: obj.test_memory() and returns: unittest