code: def test_offload_weight(self):
      dtypes = [torch.float16, torch.float32, torch.bfloat16]
  
      for dtype in dtypes:
          weight = torch.randn(2, 3, dtype=dtype)
          with TemporaryDirectory() as tmp_dir:
              index = offload_weight(weight, "weight", tmp_dir, {})
              weight_file = os.path.join(tmp_dir, "weight.dat")
              self.assertTrue(os.path.isfile(weight_file))
              self.assertDictEqual(
                  index,
                  {
                      "weight": {
                          "shape": [2, 3],
                          "dtype": str(dtype).split(".")[1],
                      }
                  },
              )
  
              new_weight = load_offloaded_weight(
                  weight_file, index["weight"]
              )
              self.assertTrue(torch.equal(weight, new_weight))
  
file_path: accelerate/tests/test_offload.py
imports: import os
  import unittest
  from tempfile import TemporaryDirectory
  import torch
  import torch.nn
  from accelerate.utils import OffloadedWeightsLoader, extract_submodules_state_dict, load_offloaded_weight, offload_state_dict, offload_weight
label_desc: Use image node_id 2 for calling the OffloadTester obj's underlying member method code with example usage: obj.test_offload_weight() without return types