code: def open_file(
      filename,
      mode="r",
      encoding=None,
      errors="strict",
      lazy=False,
      atomic=False,
  ):
      """This is similar to how the :class:`File` works but for manual
      usage.  Files are opened non lazy by default.  This can open regular
      files as well as stdin/stdout if ``'-'`` is passed.
  
      If stdin/stdout is returned the stream is wrapped so that the context
      manager will not close the stream accidentally.  This makes it possible
      to always use the function like this without having to worry to
      accidentally close a standard stream::
  
          with open_file(filename) as f:
              ...
  
      .. versionadded:: 3.0
  
      :param filename: the name of the file to open (or ``'-'`` for stdin/stdout).
      :param mode: the mode in which to open the file.
      :param encoding: the encoding to use.
      :param errors: the error handling for this file.
      :param lazy: can be flipped to true to open the file lazily.
      :param atomic: in atomic mode writes go into a temporary file and it's
                     moved on close.
      """
      if lazy:
          return LazyFile(
              filename, mode, encoding, errors, atomic=atomic
          )
      f, should_close = open_stream(
          filename, mode, encoding, errors, atomic=atomic
      )
      if not should_close:
          f = KeepOpenFile(f)
      return f
  
imports: import os
  import sys
  from ._compat import _default_text_stderr
  from ._compat import _default_text_stdout
  from ._compat import auto_wrap_for_ansi
  from ._compat import binary_streams
  from ._compat import filename_to_ui
  from ._compat import get_filesystem_encoding
  from ._compat import get_streerror
  from ._compat import is_bytes
  from ._compat import open_stream
  from ._compat import PY2
  from ._compat import should_strip_ansi
  from ._compat import string_types
  from ._compat import strip_ansi
  from ._compat import text_streams
  from ._compat import text_type
  from ._compat import WIN
  from .globals import resolve_color_default
label_desc: Use image node_id 8 for calling a global function with example usage: open_file(filename, mode, encoding, errors, lazy, atomic) and returns: f, LazyFile