code: def save_data(data, path, fmt):
      """Save data into disk."""
      # Make sure the directory exists.
      os.makedirs(os.path.dirname(path), exist_ok=True)
  
      if fmt not in ["numpy", "torch"]:
          raise RuntimeError(f"Unsupported format: {fmt}")
  
      # Perform necessary conversion.
      if fmt == "numpy" and isinstance(data, torch.Tensor):
          data = data.cpu().numpy()
      elif fmt == "torch" and isinstance(data, np.ndarray):
          data = torch.from_numpy(data).cpu()
  
      # Save the data.
      if fmt == "numpy":
          if not data.flags["C_CONTIGUOUS"]:
              Warning(
                  "The ndarray saved to disk is not contiguous, "
                  "so it will be copied to contiguous memory."
              )
              data = np.ascontiguousarray(data)
          np.save(path, data)
      elif fmt == "torch":
          if not data.is_contiguous():
              Warning(
                  "The tensor saved to disk is not contiguous, "
                  "so it will be copied to contiguous memory."
              )
              data = data.contiguous()
          torch.save(data, path)
  
file_path: dgl/python/dgl/graphbolt/internal/utils.py
imports: import hashlib
  import json
  import os
  import shutil
  from typing import List, Union
  import numpy
  import pandas
  import torch
  from numpy.lib.format import read_array_header_1_0, read_array_header_2_0
label_desc: Use image node_id 4 for calling a global function with example usage: save_data(data, path, fmt) without return types