code: def _write_graph_to_picklez_file(graph, fname=None, version=-1):
      """Saves the graph in Python pickled format, compressed with
      gzip.
  
      Saving in this format is a bit slower than saving in a Python pickle
      without compression, but the final file takes up much less space on
      the hard drive.
  
      @param fname: the name of the file or a stream to save to.
      @param version: pickle protocol version to be used. If -1, uses
        the highest protocol available
      @return: C{None} if the graph was saved successfully to the
        given file.
      """
      import pickle as pickle
  
      file_was_opened = False
  
      if not hasattr(fname, "write"):
          file_was_opened = True
          fname = gzip.open(fname, "wb")
      elif not isinstance(fname, gzip.GzipFile):
          file_was_opened = True
          fname = gzip.GzipFile(mode="wb", fileobj=fname)
  
      result = pickle.dump(graph, fname, version)
  
      if file_was_opened:
          fname.close()
  
      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 12 for calling a global function with example usage: _write_graph_to_picklez_file(graph, fname, version) and returns: result