code: def _check_parity(rmodel, omodel, ropt, oopt, rloss, oloss):
      for oparams, rparams in zip(
          omodel.parameters(), rmodel.parameters()
      ):
          assert torch.allclose(
              oparams, rparams, atol=1e-2
          ), f"Model params are different {oparams} {rparams}"
  
      for o_pg, reg_pg in zip(oopt.param_groups, ropt.param_groups):
          for o_pg, reg_pg in zip(o_pg["params"], reg_pg["params"]):
              assert torch.allclose(
                  o_pg, reg_pg, atol=1e-2
              ), f"Model parameters differ in between Offlad and Vanilla {[o_pg]} {reg_pg}"
  
          for o_buf, reg_buf in zip(omodel.buffers(), rmodel.buffers()):
              assert torch.allclose(
                  o_buf, reg_buf, atol=1e-2
              ), "Model buffers differ in between Offload and Vanilla."
  
file_path: fairscale/tests/experimental/nn/test_offload.py
imports: import contextlib
  import copy
  import numpy
  import pytest
  import torch
  from fairscale.experimental.nn.offload import OffloadModel
  from fairscale.fair_dev.testing.testing import skip_if_no_cuda
  from fairscale.internal import torch_version
label_desc: Use image node_id 4 for calling a global function with example usage: _check_parity(rmodel, omodel, ropt, oopt, rloss, oloss) without return types