code: def new_portal(self):
      portal = None
  
      def new_portal(tensor_life):
          nonlocal portal
          tensor = torch.rand(1, requires_grad=True)
          portal = Portal(tensor, tensor_life)
          return portal, tensor
  
      yield new_portal
  
      # A test using this fixture must exhaust the tensor in the portal.
      with pytest.raises(RuntimeError):
          portal.check_tensor_life()
      assert portal.tensor is None
  
file_path: pytorch/test/distributed/pipeline/sync/skip/test_portal.py
imports: import pytest
  import torch
  from torch.distributed.pipeline.sync.dependency import fork, join
  from torch.distributed.pipeline.sync.skip.portal import Portal
  from torch.distributed.pipeline.sync.stream import default_stream
  from torch.testing._internal.common_utils import run_tests
label_desc: Use image node_id 1 for calling the TestTensorLife obj's underlying member method code with example usage: obj.new_portal() and returns: portal,  tensor