code: def test_not_requires_grad():
      x = Batch(torch.rand(1, requires_grad=False), 0)
      assert not x[0].requires_grad
  
      def f(x):
          return x * 2
  
      chk = Checkpointing(f, x)
      x = chk.checkpoint()
      assert x[0].requires_grad
  
      chk.recompute(x)
      assert x[0].requires_grad
  
      x.tensor.backward()
  
file_path: fairscale/tests/nn/pipe/test_checkpoint.py
imports: from functools import partial
  import pytest
  import torch
  from torch import nn
  import torch.cuda
  from fairscale.nn.pipe.checkpoint import Checkpointing, Function, TensorOrTensors, is_checkpointing, is_recomputing
  from fairscale.nn.pipe.dependency import fork, join
  from fairscale.nn.pipe.microbatch import Batch
label_desc: Use image node_id 3 for calling a global function with example usage: test_not_requires_grad() and returns: unknown