class_docstr: Class that provides function to separate/combine tensors and nontensors
  parameters.
  
  Examples
  --------
  >>> import torch
  >>> from deepchem.utils.pytorch_utils import TensorNonTensorSeparator
  >>> a = torch.tensor([1.,2,3])
  >>> b = 4.
  >>> c = torch.tensor([5.,6,7], requires_grad=True)
  >>> params = [a, b, c]
  >>> separator = TensorNonTensorSeparator(params)
  >>> tensor_params = separator.get_tensor_params()
  >>> tensor_params
  [tensor([5., 6., 7.], requires_grad=True)]
class_docstr_tok: ["Class","that","provides","function","to","separate\/combine","tensors","and","nontensors","parameters",".","Examples","--","--","--","--",">",">",">","import","torch",">",">",">","from","deepchem.utils.pytorch_utils","import","TensorNonTensorSeparator",">",">",">","a","=","torch.tensor","(","[","1.,2,3","]",")",">",">",">","b","=","4",".",">",">",">","c","=","torch.tensor","(","[","5.,6,7","]",",","requires_grad=True",")",">",">",">","params","=","[","a",",","b",",","c","]",">",">",">","separator","=","TensorNonTensorSeparator","(","params",")",">",">",">","tensor_params","=","separator.get_tensor_params","(",")",">",">",">","tensor_params","[","tensor","(","[","5.",",","6.",",","7",".","]",",","requires_grad=True",")","]"]
docstr: Initialize the TensorNonTensorSeparator.
  
  Parameters
  ----------
  params: List[torch.Tensor]
      A list of tensor or non-tensor parameters.
  varonly: bool
      If True, only tensor parameters with requires_grad=True will be
      returned. Otherwise, all tensor parameters will be returned.
docstr_tok: ["Initialize","the","TensorNonTensorSeparator",".","Parameters","--","--","--","--","--","params",":","List","[","torch.Tensor","]","A","list","of","tensor","or","non-tensor","parameters",".","varonly",":","bool","If","True",",","only","tensor","parameters","with","requires_grad=True","will","be","returned",".","Otherwise",",","all","tensor","parameters","will","be","returned","."]
code: def __init__(self, params: List[torch.Tensor], varonly: bool = True):
      """Initialize the TensorNonTensorSeparator.
  
      Parameters
      ----------
      params: List[torch.Tensor]
          A list of tensor or non-tensor parameters.
      varonly: bool
          If True, only tensor parameters with requires_grad=True will be
          returned. Otherwise, all tensor parameters will be returned.
  
      """
      self.tensor_idxs = []
      self.tensor_params = []
      self.nontensor_idxs = []
      self.nontensor_params = []
      self.nparams = len(params)
      for i, p in enumerate(params):
          if isinstance(p, torch.Tensor) and (
              (varonly and p.requires_grad) or (not varonly)
          ):
              self.tensor_idxs.append(i)
              self.tensor_params.append(p)
          else:
              self.nontensor_idxs.append(i)
              self.nontensor_params.append(p)
      self.alltensors = len(self.tensor_idxs) == self.nparams
  
file_path: deepchem/deepchem/utils/pytorch_utils.py
imports: import scipy
  import torch
  from typing import Callable, Union, List, Generator, Tuple
label_desc: Use image node_id 1 to create a new TensorNonTensorSeparator object from inherited base classes: object with example: obj = TensorNonTensorSeparator(params, varonly)