code: def _python2_gzipopen(fn, mode, encoding, newline):
      """Wrapper to open gzip in text mode.
  
      Parameters
      ----------
      fn : str, bytes, file
          File path or opened file.
      mode : str
          File mode. The actual files are opened as binary, but will decoded
          using the specified `encoding` and `newline`.
      encoding : str
          Encoding to be used when reading/writing as text.
      newline : str
          Newline to be used when reading/writing as text.
  
      """
      import gzip
  
      # gzip is lacking read1 needed for TextIOWrapper
      class GzipWrap(gzip.GzipFile):
          def read1(self, n):
              return self.read(n)
  
      _check_mode(mode, encoding, newline)
  
      gz_mode = mode.replace("t", "")
  
      if isinstance(fn, (str, bytes)):
          binary_file = GzipWrap(fn, gz_mode)
      elif hasattr(fn, "read") or hasattr(fn, "write"):
          binary_file = GzipWrap(None, gz_mode, fileobj=fn)
      else:
          raise TypeError(
              "filename must be a str or bytes object, or a file"
          )
  
      if "t" in mode:
          return io.TextIOWrapper(
              binary_file, encoding, newline=newline
          )
      else:
          return binary_file
  
imports: from __future__ import division, absolute_import, print_function
  import os
  import sys
  import warnings
  import shutil
  import io
  from numpy.core.overrides import set_module
label_desc: Use image node_id 3 for calling a global function with example usage: _python2_gzipopen(fn, mode, encoding, newline) and returns: io, binary_file, self