code: def test_save_data(data_fmt, save_fmt, contiguous):
      with tempfile.TemporaryDirectory() as test_dir:
          data = np.array([[1, 2, 4], [2, 5, 3]])
          if not contiguous:
              data = np.asfortranarray(data)
          tensor_data = torch.from_numpy(data)
          type_name = "pt" if save_fmt == "torch" else "npy"
          save_file_name = os.path.join(
              test_dir, f"save_data.{type_name}"
          )
          # Step1. Save the data.
          if data_fmt == "torch":
              internal.save_data(tensor_data, save_file_name, save_fmt)
          elif data_fmt == "numpy":
              internal.save_data(data, save_file_name, save_fmt)
  
          # Step2. Load the data.
          if save_fmt == "torch":
              loaded_data = torch.load(save_file_name)
              assert loaded_data.is_contiguous()
              assert torch.equal(tensor_data, loaded_data)
          elif save_fmt == "numpy":
              loaded_data = np.load(save_file_name)
              # Checks if the loaded data is C-contiguous.
              assert loaded_data.flags["C_CONTIGUOUS"]
              assert np.array_equal(tensor_data.numpy(), loaded_data)
  
          data = tensor_data = loaded_data = None
  
file_path: dgl/tests/python/pytorch/graphbolt/utils/test_internal.py
imports: import json
  import os
  import re
  import tempfile
  import dgl.graphbolt.internal
  import numpy
  import pandas
  import pytest
  import torch
label_desc: Use image node_id 4 for calling a global function with example usage: test_save_data(data_fmt, save_fmt, contiguous) without return types