code: def test_use_grad():
      tensor = torch.rand(1, requires_grad=True)
      portal = Portal(tensor, tensor_life=1, index=0)
  
      portal.put_grad(tensor)
      assert portal.use_grad() is tensor
  
      # Gradient in a portal is ephemeral.
      with pytest.raises(RuntimeError):
          portal.use_grad()
  
file_path: fairscale/tests/nn/pipe/skip/test_portal.py
imports: import pytest
  import torch
  from fairscale.nn.pipe.dependency import fork, join
  from fairscale.nn.pipe.skip.portal import Portal
  from fairscale.nn.pipe.stream import default_stream
label_desc: Use image node_id 4 for calling a global function with example usage: test_use_grad() without return types