class_docstr: Calculate structure graph features for crystals.
  
  Based on the implementation in Crystal Graph Convolutional
  Neural Networks (CGCNN). The method constructs a crystal graph
  representation including atom features and bond features (neighbor
  distances). Neighbors are determined by searching in a sphere around
  atoms in the unit cell. A Gaussian filter is applied to neighbor distances.
  All units are in angstrom.
  
  This featurizer requires the optional dependency pymatgen. It may
  be useful when 3D coordinates are available and when using graph
  network models and crystal graph convolutional networks.
  
  See [1]_ for more details.
  
  References
  ----------
  .. [1] T. Xie and J. C. Grossman, "Crystal graph convolutional
      neural networks for an accurate and interpretable prediction
      of material properties", Phys. Rev. Lett. 120, 2018,
      https://arxiv.org/abs/1710.10324
  
  Examples
  --------
  >>> import deepchem as dc
  >>> import pymatgen as mg
  >>> featurizer = dc.feat.CGCNNFeaturizer()
  >>> lattice = mg.core.Lattice.cubic(4.2)
  >>> structure = mg.core.Structure(lattice, ["Cs", "Cl"], [[0, 0, 0], [0.5, 0.5, 0.5]])
  >>> features = featurizer.featurize([structure])
  >>> feature = features[0]
  >>> print(type(feature))
  <class 'deepchem.feat.graph_data.GraphData'>
  
  Note
  ----
  This class requires Pymatgen to be installed.
class_docstr_tok: ["Calculate","structure","graph","features","for","crystals",".","Based","on","the","implementation","in","Crystal","Graph","Convolutional","Neural","Networks","(","CGCNN",")",".","The","method","constructs","a","crystal","graph","representation","including","atom","features","and","bond","features","(","neighbor","distances",")",".","Neighbors","are","determined","by","searching","in","a","sphere","around","atoms","in","the","unit","cell",".","A","Gaussian","filter","is","applied","to","neighbor","distances",".","All","units","are","in","angstrom",".","This","featurizer","requires","the","optional","dependency","pymatgen",".","It","may","be","useful","when","3D","coordinates","are","available","and","when","using","graph","network","models","and","crystal","graph","convolutional","networks",".","See","[","1","]","_","for","more","details",".","References","--","--","--","--","--","..","[","1","]","T.","Xie","and","J.","C.","Grossman",",","``","Crystal","graph","convolutional","neural","networks","for","an","accurate","and","interpretable","prediction","of","material","properties","''",",","Phys",".","Rev",".","Lett",".","120",",","2018",",","https",":","\/\/arxiv.org\/abs\/1710.10324","Examples","--","--","--","--",">",">",">","import","deepchem","as","dc",">",">",">","import","pymatgen","as","mg",">",">",">","featurizer","=","dc.feat.CGCNNFeaturizer","(",")",">",">",">","lattice","=","mg.core.Lattice.cubic","(","4.2",")",">",">",">","structure","=","mg.core.Structure","(","lattice",",","[","``","Cs","''",",","``","Cl","''","]",",","[","[","0",",","0",",","0","]",",","[","0.5",",","0.5",",","0.5","]","]",")",">",">",">","features","=","featurizer.featurize","(","[","structure","]",")",">",">",">","feature","=","features","[","0","]",">",">",">","print","(","type","(","feature",")",")","<","class","'deepchem.feat.graph_data.GraphData","'",">","Note","--","--","This","class","requires","Pymatgen","to","be","installed","."]
docstr: Calculate the edge feature and edge index from pymatgen structure.
  
  Parameters
  ----------
  struct: pymatgen.core.Structure
      A periodic crystal composed of a lattice and a sequence of atomic
      sites with 3D coordinates and elements.
  
  Returns
  -------
  edge_idx np.ndarray, dtype int
      A numpy array of shape with `(2, num_edges)`.
  edge_features: np.ndarray
      A numpy array of shape with `(num_edges, filter_length)`. The `filter_length` is
      (self.radius / self.step) + 1. The edge features were built by applying gaussian
      filter to the distance between nodes.
docstr_tok: ["Calculate","the","edge","feature","and","edge","index","from","pymatgen","structure",".","Parameters","--","--","--","--","--","struct",":","pymatgen.core.Structure","A","periodic","crystal","composed","of","a","lattice","and","a","sequence","of","atomic","sites","with","3D","coordinates","and","elements",".","Returns","--","--","--","-","edge_idx","np.ndarray",",","dtype","int","A","numpy","array","of","shape","with","`","(","2",",","num_edges",")","`",".","edge_features",":","np.ndarray","A","numpy","array","of","shape","with","`","(","num_edges",",","filter_length",")","`",".","The","`","filter_length","`","is","(","self.radius","\/","self.step",")","+","1",".","The","edge","features","were","built","by","applying","gaussian","filter","to","the","distance","between","nodes","."]
code: def _get_edge_features_and_index(
      self, struct: PymatgenStructure
  ) -> Tuple[np.ndarray, np.ndarray]:
      """
      Calculate the edge feature and edge index from pymatgen structure.
  
      Parameters
      ----------
      struct: pymatgen.core.Structure
          A periodic crystal composed of a lattice and a sequence of atomic
          sites with 3D coordinates and elements.
  
      Returns
      -------
      edge_idx np.ndarray, dtype int
          A numpy array of shape with `(2, num_edges)`.
      edge_features: np.ndarray
          A numpy array of shape with `(num_edges, filter_length)`. The `filter_length` is
          (self.radius / self.step) + 1. The edge features were built by applying gaussian
          filter to the distance between nodes.
      """
  
      neighbors = struct.get_all_neighbors(
          self.radius, include_index=True
      )
      neighbors = [sorted(n, key=lambda x: x[1]) for n in neighbors]
  
      # construct bi-directed graph
      src_idx, dest_idx = [], []
      edge_distances = []
      for node_idx, neighbor in enumerate(neighbors):
          neighbor = neighbor[: self.max_neighbors]
          src_idx.extend([node_idx] * len(neighbor))
          dest_idx.extend([site[2] for site in neighbor])
          edge_distances.extend([site[1] for site in neighbor])
  
      edge_idx = np.array([src_idx, dest_idx], dtype=int)
      edge_features = self._gaussian_filter(
          np.array(edge_distances, dtype=float)
      )
      return edge_idx, edge_features
  
file_path: deepchem/deepchem/feat/material_featurizers/cgcnn_featurizer.py
imports: import os
  import json
  import logging
  import numpy
  from typing import Tuple
  from urllib.error import URLError
  from deepchem.utils.data_utils import download_url, get_data_dir
  from deepchem.utils.typing import PymatgenStructure
  from deepchem.feat import MaterialStructureFeaturizer
  from deepchem.feat.graph_data import GraphData
label_desc: Use image node_id 4 for calling the CGCNNFeaturizer obj's underlying member method code with example usage: obj._get_edge_features_and_index(struct) and returns: edge_idx,  edge_features