code: def _construct_graph_from_pickle_file(cls, fname=None):
      """Reads a graph from Python pickled format
  
      @param fname: the name of the file, a stream to read from, or
        a string containing the pickled data.
      @return: the created graph object.
      """
      import pickle as pickle
  
      if hasattr(fname, "read"):
          # Probably a file or a file-like object
          result = pickle.load(fname)
      else:
          try:
              fp = open(fname, "rb")
          except UnicodeDecodeError:
              try:
                  # We are on Python 3.6 or above and we are passing a pickled
                  # stream that cannot be decoded as Unicode. Try unpickling
                  # directly.
                  result = pickle.loads(fname)
              except TypeError:
                  raise IOError(
                      "Cannot load file. If fname is a file name, that "
                      "filename may be incorrect."
                  ) from None
          except IOError:
              try:
                  # No file with the given name, try unpickling directly.
                  result = pickle.loads(fname)
              except TypeError:
                  raise IOError(
                      "Cannot load file. If fname is a file name, that "
                      "filename may be incorrect."
                  ) from None
          else:
              result = pickle.load(fp)
              fp.close()
  
      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 5 for calling a global function with example usage: _construct_graph_from_pickle_file(cls, fname) and returns: result