code: def check_update(filename, generated, force=False):
      original = ""
      if os.path.exists(filename):
          with io.open(filename, "rt", encoding="utf_8_sig") as f:
              original = six.text_type(f.read())
      s = difflib.SequenceMatcher(None, original, generated)
  
      if (force or not os.path.exists(filename)) and s.ratio() < 1.0:
          with open(filename, "wb") as f:
              print("Updating {}.".format(filename))
              write_content = generated.encode("utf_8")
              write_content = write_content.replace(b"\r\n", b"\n")
              write_content = write_content.replace(b"\r", b"\n")
              f.write(write_content)
  
imports: import difflib
  import io
  import os
  import six
label_desc: Use image node_id 1 for calling a global function with example usage: check_update(filename, generated, force) without return types