code: def replace_files(template_filepath, handlebar_and_filepath):
      replacements = {}
      for handlebar, filepath in handlebar_and_filepath.items():
          with open(filepath, "rb") as f:
              res = f.read()
              digest = hashlib.sha256(res).hexdigest()
  
          basename = os.path.basename(filepath)
          replacements[handlebar] = (
              basename + "?_file_hash=%s" % digest[:8]
          )
  
      with open(template_filepath, "r") as f:
          template = f.read()
  
      return re.sub(
          "|".join(re.escape(k) for k in replacements),
          lambda k: replacements[k.group()],
          template,
      )
  
imports: import hashlib
  import os
  import sys
  import re
label_desc: Use image node_id 1 for calling a global function with example usage: replace_files(template_filepath, handlebar_and_filepath) and returns: re