code: def inplace_on_requires_grad(pipe_class):
      model = nn.Sequential(nn.Linear(1, 1), nn.ReLU(inplace=True))
      model = pipe_class(
          model,
          [1, 1],
          worker_map=get_worker_map(),
          checkpoint="always",
      )
  
      x = torch.rand(1)
  
      if pipe_class == AsyncPipe and model.group.rank() == 0:
          # With AsyncPipe, model will wait forever for gradients if not eval
          model.eval()
  
      y = model(x)
  
      message = r"a leaf Variable that requires grad .* used in an in-place operation."
      if model.group.rank() == 1:
          with pytest.raises(RuntimeError, match=message):
              y.backward()
  
      torch.distributed.barrier()
  
imports: import pytest
  import torch
  from torch import nn
  from fairscale.fair_dev.testing.testing import get_worker_map, torch_spawn
  from fairscale.nn.pipe import AsyncPipe
label_desc: Use image node_id 1 for calling a global function with example usage: inplace_on_requires_grad(pipe_class) without return types