code: def check_embedding(G, embedding):
      """Raises an exception if the combinatorial embedding is not correct
  
      Parameters
      ----------
      G : NetworkX graph
      embedding : a dict mapping nodes to a list of edges
          This specifies the ordering of the outgoing edges from a node for
          a combinatorial embedding
  
      Notes
      -----
      Checks the following things:
          - The type of the embedding is correct
          - The nodes and edges match the original graph
          - Every half edge has its matching opposite half edge
          - No intersections of edges (checked by Euler's formula)
      """
  
      if not isinstance(embedding, nx.PlanarEmbedding):
          raise nx.NetworkXException(
              "Bad embedding. Not of type nx.PlanarEmbedding"
          )
  
      # Check structure
      embedding.check_structure()
  
      # Check that graphs are equivalent
  
      assert set(G.nodes) == set(
          embedding.nodes
      ), "Bad embedding. Nodes don't match the original graph."
  
      # Check that the edges are equal
      g_edges = set()
      for edge in G.edges:
          if edge[0] != edge[1]:
              g_edges.add((edge[0], edge[1]))
              g_edges.add((edge[1], edge[0]))
      assert g_edges == set(
          embedding.edges
      ), "Bad embedding. Edges don't match the original graph."
  
imports: import pytest
  import networkx
  from networkx.algorithms.planarity import check_planarity_recursive, get_counterexample, get_counterexample_recursive
label_desc: Use image node_id 1 for calling a global function with example usage: check_embedding(G, embedding) without return types