class_docstr: Class for sparse matrix.
class_docstr_tok: ["Class","for","sparse","matrix","."]
docstr: Returns a sub-matrix selected according to the given range index.
  
  Parameters
  ----------
  dim : int
      The dim to select from matrix, should be 0 or 1. `dim = 0` for
      rowwise selection and `dim = 1` for columnwise selection.
  index : slice
      The selection slice indicates ID index from the `dim` should
      be chosen from the matrix.
  
  The function does not support autograd.
  
  Returns
  -------
  SparseMatrix
      The sub-matrix which contains selected rows or columns.
  
  Examples
  --------
  
  >>> indices = torch.tensor([0, 1, 1, 2, 3, 4], [0, 2, 4, 3, 5, 0]])
  >>> val = torch.tensor([0, 1, 2, 3, 4, 5])
  >>> A = dglsp.spmatrix(indices, val)
  
  Case 1: Select rows with given slice object.
  
  >>> A.range_select(0, slice(1, 3))
  SparseMatrix(indices=tensor([[0, 0, 1],
                               [2, 4, 3]]),
               values=tensor([1, 2, 3]),
               shape=(2, 6), nnz=3)
  
  Case 2: Select columns with given slice object.
  
  >>> A.range_select(1, slice(3, 6))
  SparseMatrix(indices=tensor([[2, 1, 3],
                               [0, 1, 2]]),
               values=tensor([3, 2, 4]),
               shape=(5, 3), nnz=3)
docstr_tok: ["Returns","a","sub-matrix","selected","according","to","the","given","range","index",".","Parameters","--","--","--","--","--","dim",":","int","The","dim","to","select","from","matrix",",","should","be","0","or","1",".","`","dim","=","0","`","for","rowwise","selection","and","`","dim","=","1","`","for","columnwise","selection",".","index",":","slice","The","selection","slice","indicates","ID","index","from","the","`","dim","`","should","be","chosen","from","the","matrix",".","The","function","does","not","support","autograd",".","Returns","--","--","--","-","SparseMatrix","The","sub-matrix","which","contains","selected","rows","or","columns",".","Examples","--","--","--","--",">",">",">","indices","=","torch.tensor","(","[","0",",","1",",","1",",","2",",","3",",","4","]",",","[","0",",","2",",","4",",","3",",","5",",","0","]","]",")",">",">",">","val","=","torch.tensor","(","[","0",",","1",",","2",",","3",",","4",",","5","]",")",">",">",">","A","=","dglsp.spmatrix","(","indices",",","val",")","Case","1",":","Select","rows","with","given","slice","object",".",">",">",">","A.range_select","(","0",",","slice","(","1",",","3",")",")","SparseMatrix","(","indices=tensor","(","[","[","0",",","0",",","1","]",",","[","2",",","4",",","3","]","]",")",",","values=tensor","(","[","1",",","2",",","3","]",")",",","shape=","(","2",",","6",")",",","nnz=3",")","Case","2",":","Select","columns","with","given","slice","object",".",">",">",">","A.range_select","(","1",",","slice","(","3",",","6",")",")","SparseMatrix","(","indices=tensor","(","[","[","2",",","1",",","3","]",",","[","0",",","1",",","2","]","]",")",",","values=tensor","(","[","3",",","2",",","4","]",")",",","shape=","(","5",",","3",")",",","nnz=3",")"]
code: def range_select(self, dim: int, index: slice):
      """Returns a sub-matrix selected according to the given range index.
  
      Parameters
      ----------
      dim : int
          The dim to select from matrix, should be 0 or 1. `dim = 0` for
          rowwise selection and `dim = 1` for columnwise selection.
      index : slice
          The selection slice indicates ID index from the `dim` should
          be chosen from the matrix.
  
      The function does not support autograd.
  
      Returns
      -------
      SparseMatrix
          The sub-matrix which contains selected rows or columns.
  
      Examples
      --------
  
      >>> indices = torch.tensor([0, 1, 1, 2, 3, 4], [0, 2, 4, 3, 5, 0]])
      >>> val = torch.tensor([0, 1, 2, 3, 4, 5])
      >>> A = dglsp.spmatrix(indices, val)
  
      Case 1: Select rows with given slice object.
  
      >>> A.range_select(0, slice(1, 3))
      SparseMatrix(indices=tensor([[0, 0, 1],
                                   [2, 4, 3]]),
                   values=tensor([1, 2, 3]),
                   shape=(2, 6), nnz=3)
  
      Case 2: Select columns with given slice object.
  
      >>> A.range_select(1, slice(3, 6))
      SparseMatrix(indices=tensor([[2, 1, 3],
                                   [0, 1, 2]]),
                   values=tensor([3, 2, 4]),
                   shape=(5, 3), nnz=3)
      """
      if dim not in (0, 1):
          raise ValueError("The selection dimension should be 0 or 1.")
      if isinstance(index, slice):
          if index.step not in (None, 1):
              raise NotImplementedError(
                  "Slice with step other than 1 are not supported yet."
              )
          start = 0 if index.start is None else index.start
          end = index.stop
          return SparseMatrix(
              self.c_sparse_matrix.range_select(dim, start, end)
          )
      raise TypeError(
          f"{type(index).__name__} is unsupported input type."
      )
  
imports: from typing import Optional, Tuple
  import torch
label_desc: Use image node_id 29 for calling the SparseMatrix obj's underlying member method code with example usage: obj.range_select(dim, index) and returns: SparseMatrix