code: def to_graph6_bytes(G, nodes=None, header=True):
      """Convert a simple undirected graph to bytes in graph6 format.
  
      Parameters
      ----------
      G : Graph (undirected)
  
      nodes: list or iterable
         Nodes are labeled 0...n-1 in the order provided.  If None the ordering
         given by ``G.nodes()`` is used.
  
      header: bool
         If True add '>>graph6<<' bytes to head of data.
  
      Raises
      ------
      NetworkXNotImplemented
          If the graph is directed or is a multigraph.
  
      ValueError
          If the graph has at least ``2 ** 36`` nodes; the graph6 format
          is only defined for graphs of order less than ``2 ** 36``.
  
      Examples
      --------
      >>> nx.to_graph6_bytes(nx.path_graph(2))
      b'>>graph6<<A_\\n'
  
      See Also
      --------
      from_graph6_bytes, read_graph6, write_graph6_bytes
  
      Notes
      -----
      The returned bytes end with a newline character.
  
      The format does not support edge or node labels, parallel edges or
      self loops. If self loops are present they are silently ignored.
  
      References
      ----------
      .. [1] Graph6 specification
             <http://users.cecs.anu.edu.au/~bdm/data/formats.html>
  
      """
      if nodes is not None:
          G = G.subgraph(nodes)
      H = nx.convert_node_labels_to_integers(G)
      nodes = sorted(H.nodes())
      return b"".join(_generate_graph6_bytes(H, nodes, header))
  
file_path: networkx/networkx/readwrite/graph6.py
imports: from itertools import islice
  import networkx
  from networkx.exception import NetworkXError
  from networkx.utils import not_implemented_for, open_file
label_desc: Use image node_id 3 for calling a global function with example usage: to_graph6_bytes(G, nodes, header) and returns: bytes