code: def compare_nested_dict(dict1, dict2):
      for key in dict1:
          if key in dict2:
              if type(dict1[key]) is dict:
                  assert type(dict2[key]) is dict
                  diff = compare_nested_dict(dict1[key], dict2[key])
                  if not diff:
                      return diff
              elif type(dict1[key]) is list:
                  assert type(dict2[key]) is list
                  for i, val in enumerate(dict1[key]):
                      if isinstance(val, torch.Tensor):
                          if not torch.equal(
                              dict1[key][i], dict2[key][i]
                          ):
                              return False
                      elif val != dict2[key][i]:
                          return False
              elif type(dict1[key]) is torch.Tensor:
                  assert type(dict2[key]) is torch.Tensor
                  if not torch.equal(dict1[key], dict2[key]):
                      return False
              else:
                  if dict1[key] != dict2[key]:
                      return False
          else:
              return False
      return True
  
file_path: ColossalAI/tests/test_checkpoint_io/test_torch_fsdp_checkpoint_io.py
imports: import pytest
  import torch
  from packaging import version
  from torch.optim import SGD
  from torchvision.models import resnet18
  from utils import shared_tempdir
  import colossalai
  from colossalai.booster import Booster
  from colossalai.testing import rerun_if_address_is_in_use, spawn
label_desc: Use image node_id 1 for calling a global function with example usage: compare_nested_dict(dict1, dict2) and returns: True, False, diff, False, False, False, False