code: def _open_file(path):
      if path == "-":
          return util.StdIOContextManager(sys.stdout)
      util.ensure_dir(os.path.dirname(path))
      try:
          return open(path, "w")
      except (OSError, IOError) as e:
          cli.error(f"error opening {path}: {e}")
  
imports: import csv
  import logging
  import os
  import re
  import sys
  import time
  from guild import batch_util
  from guild import cli
  from guild import op_util
  from guild import run_util
  from guild import tfevent
  from guild import util
  from .None import runs_impl
label_desc: Use image node_id 3 for calling a global function with example usage: _open_file(path) and returns: util, open