code: def write_gexf(
      G, path, encoding="utf-8", prettyprint=True, version="1.2draft"
  ):
      """Write G in GEXF format to path.
  
      "GEXF (Graph Exchange XML Format) is a language for describing
      complex networks structures, their associated data and dynamics" [1]_.
  
      Node attributes are checked according to the version of the GEXF
      schemas used for parameters which are not user defined,
      e.g. visualization 'viz' [2]_. See example for usage.
  
      Parameters
      ----------
      G : graph
         A NetworkX graph
      path : file or string
         File or file name to write.
         File names ending in .gz or .bz2 will be compressed.
      encoding : string (optional, default: 'utf-8')
         Encoding for text data.
      prettyprint : bool (optional, default: True)
         If True use line breaks and indenting in output XML.
      version: string (optional, default: '1.2draft')
         The version of GEXF to be used for nodes attributes checking
  
      Examples
      --------
      >>> G = nx.path_graph(4)
      >>> nx.write_gexf(G, "test.gexf")
  
      # visualization data
      >>> G.nodes[0]["viz"] = {"size": 54}
      >>> G.nodes[0]["viz"]["position"] = {"x": 0, "y": 1}
      >>> G.nodes[0]["viz"]["color"] = {"r": 0, "g": 0, "b": 256}
  
  
      Notes
      -----
      This implementation does not support mixed graphs (directed and undirected
      edges together).
  
      The node id attribute is set to be the string of the node label.
      If you want to specify an id use set it as node data, e.g.
      node['a']['id']=1 to set the id of node 'a' to 1.
  
      References
      ----------
      .. [1] GEXF File Format, http://gexf.net/
      .. [2] GEXF schema, http://gexf.net/schema.html
      """
      writer = GEXFWriter(
          encoding=encoding, prettyprint=prettyprint, version=version
      )
      writer.add_graph(G)
      writer.write(path)
  
imports: import itertools
  import time
  from xml.etree.ElementTree import Element, ElementTree, SubElement, register_namespace, tostring
  import networkx
  from networkx.utils import open_file
label_desc: Use image node_id 1 for calling a global function with example usage: write_gexf(G, path, encoding, prettyprint, version) without return types