code: def __init__(
      self,
      row: Optional[torch.Tensor] = None,
      rowptr: Optional[torch.Tensor] = None,
      col: Optional[torch.Tensor] = None,
      value: Optional[torch.Tensor] = None,
      sparse_sizes: Optional[
          Tuple[Optional[int], Optional[int]]
      ] = None,
      rowcount: Optional[torch.Tensor] = None,
      colptr: Optional[torch.Tensor] = None,
      colcount: Optional[torch.Tensor] = None,
      csr2csc: Optional[torch.Tensor] = None,
      csc2csr: Optional[torch.Tensor] = None,
      is_sorted: bool = False,
      trust_data: bool = False,
  ):
      assert row is not None or rowptr is not None
      assert col is not None
      assert col.dtype == torch.long
      assert col.dim() == 1
      col = col.contiguous()
  
      M: int = 0
      if sparse_sizes is None or sparse_sizes[0] is None:
          if rowptr is not None:
              M = rowptr.numel() - 1
          elif row is not None and row.numel() > 0:
              M = int(row.max()) + 1
      else:
          _M = sparse_sizes[0]
          assert _M is not None
          M = _M
          if rowptr is not None:
              assert rowptr.numel() - 1 == M
          elif row is not None and row.numel() > 0:
              assert trust_data or int(row.max()) < M
  
      N: int = 0
      if sparse_sizes is None or sparse_sizes[1] is None:
          if col.numel() > 0:
              N = int(col.max()) + 1
      else:
          _N = sparse_sizes[1]
          assert _N is not None
          N = _N
          if col.numel() > 0:
              assert trust_data or int(col.max()) < N
  
      sparse_sizes = (M, N)
  
      if row is not None:
          assert row.dtype == torch.long
          assert row.device == col.device
          assert row.dim() == 1
          assert row.numel() == col.numel()
          row = row.contiguous()
  
      if rowptr is not None:
          assert rowptr.dtype == torch.long
          assert rowptr.device == col.device
          assert rowptr.dim() == 1
          assert rowptr.numel() - 1 == sparse_sizes[0]
          rowptr = rowptr.contiguous()
  
      if value is not None:
          assert value.device == col.device
          assert value.size(0) == col.size(0)
          value = value.contiguous()
  
      if rowcount is not None:
          assert rowcount.dtype == torch.long
          assert rowcount.device == col.device
          assert rowcount.dim() == 1
          assert rowcount.numel() == sparse_sizes[0]
          rowcount = rowcount.contiguous()
  
      if colptr is not None:
          assert colptr.dtype == torch.long
          assert colptr.device == col.device
          assert colptr.dim() == 1
          assert colptr.numel() - 1 == sparse_sizes[1]
          colptr = colptr.contiguous()
  
      if colcount is not None:
          assert colcount.dtype == torch.long
          assert colcount.device == col.device
          assert colcount.dim() == 1
          assert colcount.numel() == sparse_sizes[1]
          colcount = colcount.contiguous()
  
      if csr2csc is not None:
          assert csr2csc.dtype == torch.long
          assert csr2csc.device == col.device
          assert csr2csc.dim() == 1
          assert csr2csc.numel() == col.size(0)
          csr2csc = csr2csc.contiguous()
  
      if csc2csr is not None:
          assert csc2csr.dtype == torch.long
          assert csc2csr.device == col.device
          assert csc2csr.dim() == 1
          assert csc2csr.numel() == col.size(0)
          csc2csr = csc2csr.contiguous()
  
      self._row = row
      self._rowptr = rowptr
      self._col = col
      self._value = value
      self._sparse_sizes = tuple(sparse_sizes)
      self._rowcount = rowcount
      self._colptr = colptr
      self._colcount = colcount
      self._csr2csc = csr2csc
      self._csc2csr = csc2csr
  
      if not is_sorted and self._col.numel() > 0:
          idx = self._col.new_zeros(self._col.numel() + 1)
          idx[1:] = self.row()
          idx[1:] *= self._sparse_sizes[1]
          idx[1:] += self._col
          if (idx[1:] < idx[:-1]).any():
              max_value = self._sparse_sizes[0] * self._sparse_sizes[1]
              _, perm = index_sort(idx[1:], max_value)
              self._row = self.row()[perm]
              self._col = self._col[perm]
              if value is not None:
                  self._value = value[perm]
              self._csr2csc = None
              self._csc2csr = None
  
imports: import warnings
  from typing import List, Optional, Tuple
  import torch
  from torch_scatter import scatter_add, segment_csr
  from torch_sparse.utils import Final, index_sort
label_desc: Use image node_id 1 to create a new SparseStorage object from inherited base classes: object with example: obj = SparseStorage(row, rowptr, col, value, sparse_sizes, rowcount, colptr, colcount, csr2csc, csc2csr, is_sorted, trust_data)