code: def render_convo(opt):
      # Run
      opt.log()
      extension = validate_args(opt)
      input_file, output_file = opt["input"], opt["output"]
      height, width = opt["height"], opt["width"]
      alt_speaker = input_file.split("/")[-1][:-6]
  
      dialogs = pre_process(
          input_file, opt["num_examples"], alt_speaker
      )
  
      # Display on CLI
      if output_file is None:
          display_cli(dialogs, alt_speaker, "human")
      # Some form of output file
      else:
          html_str = gen_html(
              dialogs,
              height,
              width,
              "Rendered HTML",
              alt_speaker,
              "human",
              opt["user_icon"],
              opt["alt_icon"],
          )
          if extension == "html":
              # save to output
              with PathManager.open(output_file, "w") as file_handle:
                  file_handle.write(html_str)
          else:
              # create temp dir
              with tempfile.TemporaryDirectory() as tmpdir:
                  fname = (
                      tmpdir + "/interim.html"
                  )  # save html to interim.html in tmpdir
                  with PathManager.open(fname, "w") as file_handle:
                      file_handle.write(html_str)
                      if extension == "pdf":
                          cmd = (
                              f"{CHROME_PATH} --headless --crash-dumps-dir=/tmp"
                              f'--print-to-pdf="{output_file}" {fname}'
                          )
                      else:
                          cmd = (
                              f"{CHROME_PATH} --headless --hide-scrollbars"
                              f"--crash-dumps-dir=/tmp --window-size"
                              f"={opt['width'] * 100},{opt['height'] * 100}"
                              f'--screenshot="{output_file}" {fname}'
                          )
                      subprocess.run(
                          cmd,
                          stdout=subprocess.PIPE,
                          stderr=subprocess.PIPE,
                          shell=True,
                      )
  
imports: import os
  import json
  import random
  import tempfile
  import subprocess
  from parlai.core.params import ParlaiParser
  from parlai.core.script import ParlaiScript, register_script
  from parlai.utils.io import PathManager
label_desc: Use image node_id 9 for calling a global function with example usage: render_convo(opt) without return types