code: def copy_file_to_dir_if_newer(sourcefile, destdir):
      """
      Copy file sourcefile to directory destdir (creating it if needed),
      preserving metadata. If the destination file exists and is not
      older than the source file, the copying is skipped.
      """
      destfile = os.path.join(destdir, os.path.basename(sourcefile))
      try:
          desttime = modification_time(destfile)
      except OSError:
          # New file does not exist, destdir may or may not exist
          safe_makedirs(destdir)
      else:
          # New file already exists
          if not file_newer_than(sourcefile, desttime):
              return
      shutil.copy2(sourcefile, destfile)
  
imports: from __future__ import absolute_import
  import os
  import sys
  import re
  import io
  import codecs
  import shutil
  import tempfile
  from contextlib import contextmanager
label_desc: Use image node_id 9 for calling a global function with example usage: copy_file_to_dir_if_newer(sourcefile, destdir) without return types