code: def safe_save(obj, path, temp_path=None):
      if temp_path is None:
          temp_path = path + "._temp"
      torch.save(obj, temp_path)
      if os.path.exists(path):
          os.remove(path)
      os.rename(temp_path, path)
  
imports: import copy
  import math
  import os
  import torch
  import torch.nn
  import torch.nn.functional
  from torch.utils.data import Dataset, DataLoader
label_desc: Use image node_id 12 for calling a global function with example usage: safe_save(obj, path, temp_path) without return types