code: def get_counterexample(G):
      """Obtains a Kuratowski subgraph.
  
      Raises nx.NetworkXException if G is planar.
  
      The function removes edges such that the graph is still not planar.
      At some point the removal of any edge would make the graph planar.
      This subgraph must be a Kuratowski subgraph.
  
      Parameters
      ----------
      G : NetworkX graph
  
      Returns
      -------
      subgraph : NetworkX graph
          A Kuratowski subgraph that proves that G is not planar.
  
      """
      # copy graph
      G = nx.Graph(G)
  
      if check_planarity(G)[0]:
          raise nx.NetworkXException(
              "G is planar - no counter example."
          )
  
      # find Kuratowski subgraph
      subgraph = nx.Graph()
      for u in G:
          nbrs = list(G[u])
          for v in nbrs:
              G.remove_edge(u, v)
              if check_planarity(G)[0]:
                  G.add_edge(u, v)
                  subgraph.add_edge(u, v)
  
      return subgraph
  
imports: from collections import defaultdict
  import networkx
label_desc: Use image node_id 4 for calling a global function with example usage: get_counterexample(G) and returns: subgraph