code: def _construct_graph_from_picklez_file(cls, fname):
      """Reads a graph from compressed Python pickled format, uncompressing
      it on-the-fly.
  
      @param fname: the name of the file or a stream to read from.
      @return: the created graph object.
      """
      import pickle as pickle
  
      if hasattr(fname, "read"):
          # Probably a file or a file-like object
          if isinstance(fname, gzip.GzipFile):
              result = pickle.load(fname)
          else:
              result = pickle.load(
                  gzip.GzipFile(mode="rb", fileobj=fname)
              )
      else:
          result = pickle.load(gzip.open(fname, "rb"))
  
      if not isinstance(result, cls):
          raise TypeError("unpickled object is not a %s" % cls.__name__)
  
      return result
  
file_path: python-igraph/src/igraph/io/files.py
imports: import gzip
  import os
  from shutil import copyfileobj
  from warnings import warn
  from igraph._igraph import GraphBase
  from igraph.utils import named_temporary_file
label_desc: Use image node_id 6 for calling a global function with example usage: _construct_graph_from_picklez_file(cls, fname) and returns: result