code: def checkpoint_memory():
      """This test is meant to be run manually, since it depends on
      memory_profiler and its behavior may vary."""
      try:
          from memory_profiler import memory_usage
      except ImportError:
          return
  
      def f(a):
          for _ in range(10):
              a = np.sin(a**2 + 1)
          return a
  
      checkpointed_f = checkpoint(f)
  
      def testfun(f, x):
          for _ in range(5):
              x = f(x)
          return np.sum(x)
  
      gradfun = grad(testfun, 1)
  
      A = npr.RandomState(0).randn(100000)
      max_usage = max(memory_usage((gradfun, (f, A))))
      max_checkpointed_usage = max(
          memory_usage((gradfun, (checkpointed_f, A)))
      )
  
      assert max_checkpointed_usage < max_usage / 2.0
  
imports: from __future__ import absolute_import
  from builtins import range
  import warnings
  from functools import partial
  import autograd.numpy
  import autograd.numpy.random
  from autograd.test_util import check_grads, check_equivalent
  from autograd.tracer import primitive, isbox
  from autograd import grad, elementwise_grad, jacobian, value_and_grad, hessian_tensor_product, hessian, make_hvp, tensor_jacobian_product, checkpoint, make_jvp, make_ggnvp, grad_and_aux
label_desc: Use image node_id 23 for calling a global function with example usage: checkpoint_memory() and returns: a, np