code: def _test_fwd_and_bwd(
      model: torch.nn.Module, gm: ColoGraphModule, data: torch.Tensor
  ):
      # test forward
      non_fx_out = model(data)
      fx_out = gm(data)
      assert torch.equal(
          non_fx_out, fx_out
      ), "fx_out doesn't comply with original output"
  
      # test backward
      loss0 = non_fx_out.sum()
      loss0.backward()
      loss1 = fx_out.sum()
      loss1.backward()
      assert _is_all_gradient_close(
          model, gm
      ), "gm doesn't have the same gradient as original one"
  
file_path: ColossalAI/tests/test_fx/test_codegen/test_offload_codegen.py
imports: import copy
  import pytest
  import torch
  from torch.fx import GraphModule
  import colossalai
  from colossalai.fx import ColoTracer
  from colossalai.fx.graph_module import ColoGraphModule
  from colossalai.legacy.core import global_context
  from colossalai.testing import rerun_if_address_is_in_use, spawn
label_desc: Use image node_id 2 for calling a global function with example usage: _test_fwd_and_bwd(model, gm, data) without return types