code: def write_jsonl(
      filename: str, data: Iterable[Dict], append: bool = False
  ):
      """
      Writes an iterable of dictionaries to jsonl
      """
      if append:
          mode = "ab"
      else:
          mode = "wb"
      filename = os.path.expanduser(filename)
      if filename.endswith(".gz"):
          with open(filename, mode) as fp:
              with gzip.GzipFile(fileobj=fp, mode="wb") as gzfp:
                  for x in data:
                      gzfp.write((json.dumps(x) + "\n").encode("utf-8"))
      else:
          with open(filename, mode) as fp:
              for x in data:
                  fp.write((json.dumps(x) + "\n").encode("utf-8"))
  
imports: from typing import Iterable, Dict
  import gzip
  import json
  import os
label_desc: Use image node_id 3 for calling a global function with example usage: write_jsonl(filename, data, append) without return types