code: def test_multiin_multiout(device, multiout, checkpoint_config):
      if "cuda" in device and not torch.cuda.is_available():
          pytest.skip("test requires a GPU")
  
      def train(model, in1, in2):
          out = model(in1, x2=in2)
          if isinstance(out, tuple):
              out = torch.cat(out)
          loss = out.sum()
          loss.backward()
          gnorm = torch.norm(
              torch.stack(
                  [
                      torch.norm(p.grad.detach())
                      for p in model.parameters()
                  ]
              )
          )
          return {"loss": loss.item(), "gnorm": gnorm.item()}
  
      in1 = torch.rand(4, 1, 32, 32).requires_grad_(True)
      in2 = torch.rand(4, 3, 32, 32).requires_grad_(True)
  
      model = MultiinMultioutModel(multiout, 0).to(device)
      no_cpt = train(model, in1.to(device), in2.to(device))
  
      model = MultiinMultioutModel(multiout, checkpoint_config).to(
          device
      )
      cpt = train(model, in1.to(device), in2.to(device))
  
      for key in ["loss", "gnorm"]:
          if no_cpt[key] != cpt[key]:
              print(no_cpt, cpt)
              assert 0
  
imports: import pytest
  import torch
  import torch.nn
  from torch.utils.checkpoint import checkpoint
  from fairscale.fair_dev.testing.testing import skip_if_no_cuda
  from fairscale.internal import torch_version
  from fairscale.nn.checkpoint.checkpoint_activations import checkpoint_wrapper, disable_checkpointing
  from fairscale.nn.misc import FlattenParamsWrapper
  from fairscale.nn.misc import checkpoint_wrapper
label_desc: Use image node_id 5 for calling a global function with example usage: test_multiin_multiout(device, multiout, checkpoint_config) and returns: dict