code: def tensor_product(G, H):
      r"""Returns the tensor product of G and H.
  
      The tensor product $P$ of the graphs $G$ and $H$ has a node set that
      is the Cartesian product of the node sets, $V(P)=V(G) \times V(H)$.
      $P$ has an edge $((u,v), (x,y))$ if and only if $(u,x)$ is an edge in $G$
      and $(v,y)$ is an edge in $H$.
  
      Tensor product is sometimes also referred to as the categorical product,
      direct product, cardinal product or conjunction.
  
  
      Parameters
      ----------
      G, H: graphs
       Networkx graphs.
  
      Returns
      -------
      P: NetworkX graph
       The tensor product of G and H. P will be a multi-graph if either G
       or H is a multi-graph, will be a directed if G and H are directed,
       and undirected if G and H are undirected.
  
      Raises
      ------
      NetworkXError
       If G and H are not both directed or both undirected.
  
      Notes
      -----
      Node attributes in P are two-tuple of the G and H node attributes.
      Missing attributes are assigned None.
  
      Examples
      --------
      >>> G = nx.Graph()
      >>> H = nx.Graph()
      >>> G.add_node(0, a1=True)
      >>> H.add_node("a", a2="Spam")
      >>> P = nx.tensor_product(G, H)
      >>> list(P)
      [(0, 'a')]
  
      Edge attributes and edge keys (for multigraphs) are also copied to the
      new product graph
      """
      GH = _init_product_graph(G, H)
      GH.add_nodes_from(_node_product(G, H))
      GH.add_edges_from(_directed_edges_cross_edges(G, H))
      if not GH.is_directed():
          GH.add_edges_from(_undirected_edges_cross_edges(G, H))
      return GH
  
file_path: networkx/networkx/algorithms/operators/product.py
imports: from itertools import product
  import networkx
  from networkx.utils import not_implemented_for
label_desc: Use image node_id 9 for calling a global function with example usage: tensor_product(G, H) and returns: GH