code: def file_write_safe(path, data):
      """Write data to a temporary file, then move to the destination path."""
      fh = tempfile.NamedTemporaryFile(mode="w", delete=False)
      fh.write(data)
      fh.close()
      cmd = 'mv "%s" "%s"' % (fh.name, path)
      sh(cmd)
  
file_path: auptimizer/src/aup/Proposer/spearmint/helpers.py
imports: import os
  import sys
  import subprocess
  import tempfile
  from google.protobuf import text_format
  from .spearmint_pb2 import *
label_desc: Use image node_id 6 for calling a global function with example usage: file_write_safe(path, data) without return types