class_docstr: Represent a single graph with additional attributes.
class_docstr_tok: ["Represent","a","single","graph","with","additional","attributes","."]
docstr: Construct a graph from a dense (2-D NxN) adjacency matrix with
  the edge weights represented by the value of the matrix entries.
  
  Parameters
  ----------
  adj : torch.Tensor
      The tensor representing the adjacency matrix.
  
  Returns
  -------
  self
code: def from_dense_adj(self, adj: torch.Tensor):
      """
      Construct a graph from a dense (2-D NxN) adjacency matrix with
      the edge weights represented by the value of the matrix entries.
  
      Parameters
      ----------
      adj : torch.Tensor
          The tensor representing the adjacency matrix.
  
      Returns
      -------
      self
      """
      if not (adj.dim() == 2):
          raise SizeMismatchException(
              "Adjancency matrix is not 2-dimensional."
          )
      if not (adj.shape[0] == adj.shape[1]):
          raise SizeMismatchException("Adjancecy is not a square.")
      # assert adj.dim() == 2, 'Adjancency matrix is not 2-dimensional.'
      # assert adj.shape[0] == adj.shape[1], 'Adjancecy is not a square.'
  
      node_num = adj.shape[0]
      self.add_nodes(node_num)
      edge_weight = []
      for i in range(adj.shape[0]):
          for j in range(adj.shape[1]):
              if adj[i][j] != 0:
                  self.add_edge(i, j)
                  edge_weight.append(adj[i][j])
      edge_weight = torch.stack(edge_weight, dim=0)
      self.edge_features["edge_weight"] = edge_weight
      return self
  
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 26 for calling the GraphData obj's underlying member method code with example usage: obj.from_dense_adj(adj) and returns: self