class_docstr: Represent a single graph with additional attributes.
class_docstr_tok: ["Represent","a","single","graph","with","additional","attributes","."]
docstr: Return the scipy.sparse.coo_matrix form of the adjacency matrix
  Parameters
  ----------
  batch_view : bool
      Whether to return the split view of the adjacency matrix.
      Return a list of COO matrix if True
  
  Returns
  -------
  torch.Tensor or list of torch.Tensor
code: def sparse_adj(
      self, batch_view: bool = False
  ) -> Union[torch.Tensor, List[torch.Tensor]]:
      """
      Return the scipy.sparse.coo_matrix form of the adjacency matrix
      Parameters
      ----------
      batch_view : bool
          Whether to return the split view of the adjacency matrix.
          Return a list of COO matrix if True
  
      Returns
      -------
      torch.Tensor or list of torch.Tensor
      """
      row = torch.tensor(self._edge_indices[0]).to(self.device)
      col = torch.tensor(self._edge_indices[1]).to(self.device)
      data = torch.ones(self.get_edge_num()).to(self.device)
      if not batch_view:
          indices = torch.stack([row, col])
          matrix = torch.sparse_coo_tensor(
              indices=indices,
              values=data,
              size=(self.get_node_num(), self.get_node_num()),
          )
          return matrix
      else:
          if self._is_batch is not True:
              raise Exception(
                  "Cannot enable batch view of COO adjacency matrix on a non-batch graph."
              )
          matrices = []
          cum_num_edges = 0
          cum_num_nodes = 0
          for i in range(self.batch_size):
              num_edges = self._batch_num_edges[i]
              num_nodes = self._batch_num_nodes[i]
              # Slicing the matrix one by one
              cur_row = row[cum_num_edges : cum_num_edges + num_edges]
              cur_col = col[cum_num_edges : cum_num_edges + num_edges]
              cur_data = data[cum_num_edges : cum_num_edges + num_edges]
              cur_row -= cum_num_nodes
              cur_col -= cum_num_nodes
              indices = torch.stack([cur_row, cur_col])
              cur_matrix = torch.sparse_coo_tensor(
                  indices=indices,
                  values=cur_data,
                  size=(num_nodes, num_nodes),
              )
              matrices.append(cur_matrix)
              cum_num_edges += num_edges
              cum_num_nodes += num_nodes
          return matrices
  
imports: import os
  import warnings
  from collections import namedtuple
  from typing import Any, Callable, Dict, List, Tuple, Union
  import dgl
  import scipy.sparse
  import torch
  from torch.nn.utils.rnn import pad_sequence
  from .utils import EdgeNotFoundException, SizeMismatchException, check_and_expand, entail_zero_padding, int_to_list, slice_to_list
  from .views import BatchEdgeFeatView, BatchNodeFeatView, EdgeView, NodeFeatView, NodeView
label_desc: Use image node_id 29 for calling the GraphData obj's underlying member method code with example usage: obj.sparse_adj(batch_view) and returns: matrix, matrices