code: def pandoc(args, filein=None, fileout=None):
      """Execute pandoc with the given arguments"""
      cmd = ["pandoc"]
  
      if filein:
          cmd.append(filein)
  
      if fileout:
          cmd.append("-o")
          cmd.append(fileout)
  
      cmd.extend(args.split())
  
      proc = subprocess.Popen(cmd, stdout=subprocess.PIPE)
      out, err = proc.communicate()
      if proc.returncode:
          raise PandocError(
              f"pandoc exited with return code {proc.returncode}\n{str(err)}"
          )
      return out.decode("utf-8")
  
file_path: jupytext/src/jupytext/pandoc.py
imports: import os
  import subprocess
  import tempfile
  from nbformat import reads
  from nbformat import writes
  from packaging.version import parse
label_desc: Use image node_id 1 for calling a global function with example usage: pandoc(args, filein, fileout) and returns: out