class_docstr: Crystal Graph Convolutional Neural Network (CGCNN).
  
  Here is a simple example of code that uses the CGCNNModel with
  materials dataset.
  
  Examples
  --------
  >>> import deepchem as dc
  >>> dataset_config = {"reload": False, "featurizer": dc.feat.CGCNNFeaturizer(), "transformers": []}
  >>> tasks, datasets, transformers = dc.molnet.load_perovskite(**dataset_config)
  >>> train, valid, test = datasets
  >>> model = dc.models.CGCNNModel(mode='regression', batch_size=32, learning_rate=0.001)
  >>> avg_loss = model.fit(train, nb_epoch=50)
  
  This model takes arbitary crystal structures as an input, and predict material properties
  using the element information and connection of atoms in the crystal. If you want to get
  some material properties which has a high computational cost like band gap in the case
  of DFT, this model may be useful. This model is one of variants of Graph Convolutional
  Networks. The main differences between other GCN models are how to construct graphs and
  how to update node representations. This model defines the crystal graph from structures
  using distances between atoms. The crystal graph is an undirected multigraph which is defined
  by nodes representing atom properties and edges representing connections between atoms
  in a crystal. And, this model updates the node representations using both neighbor node
  and edge representations. Please confirm the detail algorithms from [1]_.
  
  References
  ----------
  .. [1] Xie, Tian, and Jeffrey C. Grossman. "Crystal graph convolutional neural networks
      for an accurate and interpretable prediction of material properties." Physical review letters
      120.14 (2018): 145301.
  
  Notes
  -----
  This class requires DGL and PyTorch to be installed.
class_docstr_tok: ["Crystal","Graph","Convolutional","Neural","Network","(","CGCNN",")",".","Here","is","a","simple","example","of","code","that","uses","the","CGCNNModel","with","materials","dataset",".","Examples","--","--","--","--",">",">",">","import","deepchem","as","dc",">",">",">","dataset_config","=","{","``","reload","''",":","False",",","``","featurizer","''",":","dc.feat.CGCNNFeaturizer","(",")",",","``","transformers","''",":","[","]","}",">",">",">","tasks",",","datasets",",","transformers","=","dc.molnet.load_perovskite","(","*","*","dataset_config",")",">",">",">","train",",","valid",",","test","=","datasets",">",">",">","model","=","dc.models.CGCNNModel","(","mode='regression","'",",","batch_size=32",",","learning_rate=0.001",")",">",">",">","avg_loss","=","model.fit","(","train",",","nb_epoch=50",")","This","model","takes","arbitary","crystal","structures","as","an","input",",","and","predict","material","properties","using","the","element","information","and","connection","of","atoms","in","the","crystal",".","If","you","want","to","get","some","material","properties","which","has","a","high","computational","cost","like","band","gap","in","the","case","of","DFT",",","this","model","may","be","useful",".","This","model","is","one","of","variants","of","Graph","Convolutional","Networks",".","The","main","differences","between","other","GCN","models","are","how","to","construct","graphs","and","how","to","update","node","representations",".","This","model","defines","the","crystal","graph","from","structures","using","distances","between","atoms",".","The","crystal","graph","is","an","undirected","multigraph","which","is","defined","by","nodes","representing","atom","properties","and","edges","representing","connections","between","atoms","in","a","crystal",".","And",",","this","model","updates","the","node","representations","using","both","neighbor","node","and","edge","representations",".","Please","confirm","the","detail","algorithms","from","[","1","]","_.","References","--","--","--","--","--","..","[","1","]","Xie",",","Tian",",","and","Jeffrey","C.","Grossman",".","``","Crystal","graph","convolutional","neural","networks","for","an","accurate","and","interpretable","prediction","of","material","properties",".","''","Physical","review","letters","120.14","(","2018",")",":","145301",".","Notes","--","--","-","This","class","requires","DGL","and","PyTorch","to","be","installed","."]
docstr: Create batch data for CGCNN.
  
  Parameters
  ----------
  batch: Tuple
      The tuple are `(inputs, labels, weights)`.
  
  Returns
  -------
  inputs: DGLGraph
      DGLGraph for a batch of graphs.
  labels: List[torch.Tensor] or None
      The labels converted to torch.Tensor
  weights: List[torch.Tensor] or None
      The weights for each sample or sample/task pair converted to torch.Tensor
docstr_tok: ["Create","batch","data","for","CGCNN",".","Parameters","--","--","--","--","--","batch",":","Tuple","The","tuple","are","`","(","inputs",",","labels",",","weights",")","`",".","Returns","--","--","--","-","inputs",":","DGLGraph","DGLGraph","for","a","batch","of","graphs",".","labels",":","List","[","torch.Tensor","]","or","None","The","labels","converted","to","torch.Tensor","weights",":","List","[","torch.Tensor","]","or","None","The","weights","for","each","sample","or","sample\/task","pair","converted","to","torch.Tensor"]
code: def _prepare_batch(self, batch):
      """Create batch data for CGCNN.
  
      Parameters
      ----------
      batch: Tuple
          The tuple are `(inputs, labels, weights)`.
  
      Returns
      -------
      inputs: DGLGraph
          DGLGraph for a batch of graphs.
      labels: List[torch.Tensor] or None
          The labels converted to torch.Tensor
      weights: List[torch.Tensor] or None
          The weights for each sample or sample/task pair converted to torch.Tensor
      """
      try:
          import dgl
      except:
          raise ImportError("This class requires DGL to be installed.")
  
      inputs, labels, weights = batch
      dgl_graphs = [graph.to_dgl_graph() for graph in inputs[0]]
      inputs = dgl.batch(dgl_graphs).to(self.device)
      _, labels, weights = super(CGCNNModel, self)._prepare_batch(
          ([], labels, weights)
      )
      return inputs, labels, weights
  
file_path: deepchem/deepchem/models/torch_models/cgcnn.py
imports: import torch
  import torch.nn
  import torch.nn.functional
  from deepchem.models.losses import Loss, L2Loss, SparseSoftmaxCrossEntropy
  from deepchem.models.torch_models.torch_model import TorchModel
label_desc: Use image node_id 2 for calling the CGCNNModel obj's underlying member method code with example usage: obj._prepare_batch(batch) and returns: inputs,  labels,  weights