code: def from_pandas_edgelist(
      df,
      source="source",
      target="target",
      edge_attr=None,
      create_using=None,
      edge_key=None,
  ):
      """cudf.DataFrame inputs also supported; value columns with str is unsuppported."""
      graph_class, inplace = _create_using_class(create_using)
      src_array = df[source].to_numpy()
      dst_array = df[target].to_numpy()
      # TODO: create renumbering helper function(s)
      # Renumber step 0: node keys
      nodes = np.unique(np.concatenate([src_array, dst_array]))
      N = nodes.size
      kwargs = {}
      if N > 0 and (
          nodes[0] != 0
          or nodes[N - 1] != N - 1
          or (
              nodes.dtype.kind not in {"i", "u"}
              and not (nodes == np.arange(N, dtype=np.int64)).all()
          )
      ):
          # We need to renumber indices--np.searchsorted to the rescue!
          kwargs["id_to_key"] = nodes.tolist()
          src_indices = cp.array(
              np.searchsorted(nodes, src_array), index_dtype
          )
          dst_indices = cp.array(
              np.searchsorted(nodes, dst_array), index_dtype
          )
      else:
          src_indices = cp.array(src_array)
          dst_indices = cp.array(dst_array)
  
      if not graph_class.is_directed():
          # Symmetrize the edges
          mask = src_indices != dst_indices
          if mask.all():
              mask = None
          src_indices, dst_indices = (
              cp.hstack(
                  (
                      src_indices,
                      dst_indices[mask]
                      if mask is not None
                      else dst_indices,
                  )
              ),
              cp.hstack(
                  (
                      dst_indices,
                      src_indices[mask]
                      if mask is not None
                      else src_indices,
                  )
              ),
          )
  
      if edge_attr is not None:
          # Additional columns requested for edge data
          if edge_attr is True:
              attr_col_headings = df.columns.difference(
                  {source, target}
              ).to_list()
          elif isinstance(edge_attr, (list, tuple)):
              attr_col_headings = edge_attr
          else:
              attr_col_headings = [edge_attr]
          if len(attr_col_headings) == 0:
              raise nx.NetworkXError(
                  "Invalid edge_attr argument: No columns found with name: "
                  f"{attr_col_headings}"
              )
          try:
              edge_values = {
                  key: cp.array(val.to_numpy())
                  for key, val in df[attr_col_headings].items()
              }
          except (KeyError, TypeError) as exc:
              raise nx.NetworkXError(
                  f"Invalid edge_attr argument: {edge_attr}"
              ) from exc
  
          if not graph_class.is_directed():
              # Symmetrize the edges
              edge_values = {
                  key: cp.hstack(
                      (val, val[mask] if mask is not None else val)
                  )
                  for key, val in edge_values.items()
              }
          kwargs["edge_values"] = edge_values
  
          if graph_class.is_multigraph() and edge_key is not None:
              try:
                  edge_keys = df[edge_key].to_list()
              except (KeyError, TypeError) as exc:
                  raise nx.NetworkXError(
                      f"Invalid edge_key argument: {edge_key}"
                  ) from exc
              if not graph_class.is_directed():
                  # Symmetrize the edges
                  edge_keys = cp.hstack(
                      (
                          edge_keys,
                          edge_keys[mask]
                          if mask is not None
                          else edge_keys,
                      )
                  )
              kwargs["edge_keys"] = edge_keys
  
      G = graph_class.from_coo(N, src_indices, dst_indices, **kwargs)
      if inplace:
          return create_using._become(G)
      return G
  
imports: import cupy
  import networkx
  import numpy
  from .generators._utils import _create_using_class
  from .utils import index_dtype, networkx_algorithm
label_desc: Use image node_id 1 for calling a global function with example usage: from_pandas_edgelist(df, source, target, edge_attr, create_using, edge_key) and returns: G, create_using