code: def write_lines_to_file(cls_name, filename, lines, metadata_dict):
    
    metadata_dict = metadata_dict or {}
    header_line = "%s%s" % (_HEADER_PREFIX, cls_name)
    metadata_line = "%s%s" % (_METADATA_PREFIX,
                              json.dumps(metadata_dict, sort_keys=True))
    with tf.io.gfile.GFile(filename, "wb") as f:
      for line in [header_line, metadata_line]:
        f.write(tf.compat.as_bytes(line))
        f.write(tf.compat.as_bytes("\n"))
      if lines:
        f.write(tf.compat.as_bytes("\n".join(lines)))
        f.write(tf.compat.as_bytes("\n"))
docs: Writes lines to file prepended by header and metadata.