class_docstr: EditableModule is a base class to enable classes that it inherits be
  converted to pure functions for higher order derivatives purpose.
  
  Usage
  -----
  To use this class, the user must implement the ``getparamnames`` method
  which returns a list of tensor names that affect the output of the method
  with name indicated in ``methodname``.
  
  Used in:
  
  - Classes of Density Functional Theory (DFT).
  
  - It can also be used in other classes that need to be converted to pure
    functions for higher order derivatives purpose.
  
  Examples
  --------
  >>> import torch
  >>> from deepchem.utils.differentiation_utils import EditableModule
  >>> class A(EditableModule):
  ...     def __init__(self, a):
  ...         self.b = a*a
  ...
  ...     def mult(self, x):
  ...         return self.b * x
  ...
  ...     def getparamnames(self, methodname, prefix=""):
  ...         if methodname == "mult":
  ...             return [prefix+"b"]
  ...         else:
  ...             raise KeyError()
  >>> a = torch.tensor(2.0).requires_grad_()
  >>> x = torch.tensor(0.4).requires_grad_()
  >>> alpha = A(a)
  >>> alpha.mult(x)
  tensor(1.6000, grad_fn=<MulBackward0>)
  >>> alpha.getparamnames("mult")
  ['b']
  >>> alpha.assertparams(alpha.mult, x)
  "mult" method check done
docstr: Returns the list of unique parameters involved in the method
  
  Parameters
  ----------
  methodname: str
      Name of the method where the returned parameters play roles.
  allparams: list of tensors
      List of tensors that are involved in the specified method of the
      object.
  
  Returns
  -------
  Sequence[int]
      List of indices of the unique parameters in the list of all parameters.
docstr_tok: ["Returns","the","list","of","unique","parameters","involved","in","the","method","Parameters","--","--","--","--","--","methodname",":","str","Name","of","the","method","where","the","returned","parameters","play","roles",".","allparams",":","list","of","tensors","List","of","tensors","that","are","involved","in","the","specified","method","of","the","object",".","Returns","--","--","--","-","Sequence","[","int","]","List","of","indices","of","the","unique","parameters","in","the","list","of","all","parameters","."]
code: def _get_unique_params_idxs(
      self,
      methodname: str,
      allparams: Union[Sequence[torch.Tensor], None] = None,
  ) -> Sequence[int]:
      """Returns the list of unique parameters involved in the method
  
      Parameters
      ----------
      methodname: str
          Name of the method where the returned parameters play roles.
      allparams: list of tensors
          List of tensors that are involved in the specified method of the
          object.
  
      Returns
      -------
      Sequence[int]
          List of indices of the unique parameters in the list of all parameters.
  
      """
  
      if not hasattr(self, "_unique_params_idxs"):
          self._unique_params_idxs = {}  # type: Dict[str,Sequence[int]]
          self._unique_params_maps = {}
          self._number_of_params = {}
  
      if methodname in self._unique_params_idxs:
          return self._unique_params_idxs[methodname]
      if allparams is None:
          allparams = self.getparams(methodname)
  
      # get the unique ids
      ids = []  # type: List[int]
      idxs = []
      idx_map = []  # type: List[List[int]]
      for i in range(len(allparams)):
          param = allparams[i]
          id_param = id(param)
  
          # search the id if it has been added to the list
          try:
              jfound = ids.index(id_param)
              idx_map[jfound].append(i)
              continue
          except ValueError:
              pass
  
          ids.append(id_param)
          idxs.append(i)
          idx_map.append([i])
  
      self._number_of_params[methodname] = len(allparams)
      self._unique_params_idxs[methodname] = idxs
      self._unique_params_maps[methodname] = idx_map
      return idxs
  
imports: import inspect
  import warnings
  from abc import abstractmethod
  import copy
  import torch
  from typing import Sequence, Union, Dict, List, Callable, Any
  from deepchem.utils.attribute_utils import get_attr, set_attr, del_attr
label_desc: Use image node_id 7 for calling the EditableModule obj's underlying member method code with example usage: obj._get_unique_params_idxs(methodname, allparams) and returns: idxs, self