code: def _gzip_open(
      filename: str,
      mode: Mode = "rb",
      compresslevel: int = 9,
      mtime: int = 0,
      keep_open: bool = False,
  ) -> gzip.GzipFile:
      if not HAVE_INDEXED_GZIP or mode != "rb":
          gzip_file = DeterministicGzipFile(
              filename, mode, compresslevel, mtime=mtime
          )
  
      # use indexed_gzip if possible for faster read access.  If keep_open ==
      # True, we tell IndexedGzipFile to keep the file handle open. Otherwise
      # the IndexedGzipFile will close/open the file on each read.
      else:
          gzip_file = IndexedGzipFile(
              filename, drop_handles=not keep_open
          )
  
      return gzip_file
  
imports: from __future__ import annotations
  import gzip
  import io
  import typing
  from bz2 import BZ2File
  from os.path import splitext
  from ._compression import HAVE_INDEXED_GZIP, IndexedGzipFile, pyzstd
label_desc: Use image node_id 1 for calling a global function with example usage: _gzip_open(filename, mode, compresslevel, mtime, keep_open) and returns: gzip_file