code: def test_no_portal_without_pipe(train, monkeypatch):
      def deny(*args, **kwargs):
          raise AssertionError("tried to create Portal without Pipe")
  
      monkeypatch.setattr(
          "fairscale.nn.pipe.skip.portal.Portal.__init__", deny
      )
  
      model = nn.Sequential(Stash(), Pop())
  
      input = torch.rand(10, requires_grad=True)
  
      if train:
          model.train()
          output = model(input)
          output.norm().backward()
      else:
          model.eval()
          with torch.no_grad():
              model(input)
  
file_path: fairscale/tests/nn/pipe/skip/test_leak.py
imports: import pytest
  import torch
  from torch import nn
  from fairscale.nn.pipe import Pipe, is_checkpointing, is_recomputing
  from fairscale.nn.pipe.skip import pop, skippable, stash
  from fairscale.nn.pipe.skip.tracker import current_skip_tracker
label_desc: Use image node_id 2 for calling a global function with example usage: test_no_portal_without_pipe(train, monkeypatch) without return types