code: def from_scipy_sparse_array(
      A,
      parallel_edges=False,
      create_using=None,
      edge_attribute="weight",
  ):
      graph_class, inplace = _create_using_class(create_using)
      m, n = A.shape
      if m != n:
          raise nx.NetworkXError(
              f"Adjacency matrix not square: nx,ny={A.shape}"
          )
      if A.format != "coo":
          A = A.tocoo()
      if (
          A.dtype.kind in {"i", "u"}
          and graph_class.is_multigraph()
          and parallel_edges
      ):
          src_indices = cp.array(np.repeat(A.row, A.data), index_dtype)
          dst_indices = cp.array(np.repeat(A.col, A.data), index_dtype)
          weight = cp.empty(src_indices.size, A.data.dtype)
          weight[:] = 1
      else:
          src_indices = cp.array(A.row, index_dtype)
          dst_indices = cp.array(A.col, index_dtype)
          weight = cp.array(A.data)
      G = graph_class.from_coo(
          n, src_indices, dst_indices, edge_values={"weight": weight}
      )
      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 2 for calling a global function with example usage: from_scipy_sparse_array(A, parallel_edges, create_using, edge_attribute) and returns: G, create_using