code: def magic_trace(
      output="trace.fxt", magic_trace_cache="/tmp/magic-trace"
  ):
      pid = os.getpid()
      if not os.path.exists(magic_trace_cache):
          print(f"Downloading magic_trace to: {magic_trace_cache}")
          subprocess.run(
              [
                  "wget",
                  "-O",
                  magic_trace_cache,
                  "-q",
                  "https://github.com/janestreet/magic-trace/releases/download/v1.0.2/magic-trace",
              ]
          )
          subprocess.run(["chmod", "+x", magic_trace_cache])
      args = [
          magic_trace_cache,
          "attach",
          "-pid",
          str(pid),
          "-o",
          output,
      ]
      p = subprocess.Popen(
          args, stderr=subprocess.PIPE, encoding="utf-8"
      )
      while True:
          x = p.stderr.readline()
          print(x)
          if "Attached" in x:
              break
      try:
          yield
      finally:
          p.send_signal(signal.SIGINT)
          r = p.wait()
          print(p.stderr.read())
          p.stderr.close()
          if r != 0:
              raise ValueError(f"magic_trace exited abnormally: {r}")
  
imports: import os
  import signal
  import subprocess
  from contextlib import contextmanager
label_desc: Use image node_id 1 for calling a global function with example usage: magic_trace(output, magic_trace_cache) without return types