code: def write_handle(path, mode=None):
      path = scope_url(path)
  
      if _supports_make_dirs(path):
          gfile.MakeDirs(os.path.dirname(path))
  
      if mode is None:
          if _supports_binary_writing(path):
              mode = "wb"
          else:
              mode = "w"
  
      handle = gfile.Open(path, mode)
      yield handle
      handle.close()
  
file_path: lucid/lucid/misc/io/writing.py
imports: from __future__ import absolute_import, division, print_function
  import os
  import logging
  from contextlib import contextmanager
  from urllib.parse import urlparse
  from tensorflow import gfile
  from lucid.misc.io.scoping import scope_url
label_desc: Use image node_id 5 for calling a global function with example usage: write_handle(path, mode) without return types