code: def _check_G_and_source(G, source):
      G = _to_graph(G)
      if source not in G:
          hash(source)  # To raise TypeError if appropriate
          raise nx.NetworkXError(
              f"The node {source} is not in the {G.__class__.__name__.lower()}."
          )
      return G
  
imports: from itertools import repeat
  import cupy
  import networkx
  import numpy
  import pylibcugraph
  import nx_cugraph
  from nx_cugraph.convert import _to_graph
  from nx_cugraph.utils import _groupby, index_dtype, networkx_algorithm
label_desc: Use image node_id 1 for calling a global function with example usage: _check_G_and_source(G, source) and returns: G