code: def _check_parity(rmodel, pmodel, ropt, popt, rloss, ploss):
      for pparams, rparams in zip(
          pmodel.parameters(), rmodel.parameters()
      ):
          assert torch.allclose(
              pparams.cuda(), rparams, atol=1e-2
          ), f"Model params are different {oparams} {rparams}"
  
      for p_pg, reg_pg in zip(popt.param_groups, ropt.param_groups):
          for p_pg, reg_pg in zip(p_pg["params"], reg_pg["params"]):
              assert torch.allclose(
                  p_pg.cuda(), reg_pg, atol=1e-2
              ), f"Model parameters differ in between Pipe and Vanilla {[o_pg]} {reg_pg}"
  
          for p_buf, reg_buf in zip(pmodel.buffers(), rmodel.buffers()):
              assert torch.allclose(
                  p_buf.cuda(), reg_buf, atol=1e-2
              ), "Model buffers differ in between Pipe and Vanilla."
  
file_path: fairscale/tests/nn/pipe/test_parity.py
imports: import contextlib
  import copy
  import numpy
  import pytest
  import torch
  from fairscale.fair_dev.testing.testing import skip_if_single_gpu
  from fairscale.nn import Pipe
label_desc: Use image node_id 2 for calling a global function with example usage: _check_parity(rmodel, pmodel, ropt, popt, rloss, ploss) without return types