docstr: Initialize site environment
  
  This class contains local site environment information. This is used
  to find neighbor list in the datum.
  
  Parameters
  ----------
  pos : np.ndarray
      n x 3 list or numpy array of (non-scaled) positions. n is the
      number of atom.
  sitetypes : List[str]
      n list of string. String must be S or A followed by a
      number. S indicates a spectator sites and A indicates a active
      sites.
  env2config: List[int]
      A particular permutation of the neighbors around an active
      site. These indexes will be used for lattice transformation.
  permutations : List[List[int]]
      p x n list of list of integer. p is the permutation
      index and n is the number of sites.
  cutoff : float
      cutoff used for pooling neighbors.
  Grtol : float (default 0.0)
      relative tolerance in distance for forming an edge in graph
  Gatol : float (default 0.01)
      absolute tolerance in distance for forming an edge in graph
  rtol : float (default 0.01)
      relative tolerance in rmsd in distance for graph matching
  atol : float (default 0.0)
      absolute tolerance in rmsd in distance for graph matching
  tol : float (default 0.01)
      maximum tolerance of position RMSD to decide whether two
      environment are the same
  grtol : float (default 0.01)
      tolerance for deciding symmetric nodes
docstr_tok: ["Initialize","site","environment","This","class","contains","local","site","environment","information",".","This","is","used","to","find","neighbor","list","in","the","datum",".","Parameters","--","--","--","--","--","pos",":","np.ndarray","n","x","3","list","or","numpy","array","of","(","non-scaled",")","positions",".","n","is","the","number","of","atom",".","sitetypes",":","List","[","str","]","n","list","of","string",".","String","must","be","S","or","A","followed","by","a","number",".","S","indicates","a","spectator","sites","and","A","indicates","a","active","sites",".","env2config",":","List","[","int","]","A","particular","permutation","of","the","neighbors","around","an","active","site",".","These","indexes","will","be","used","for","lattice","transformation",".","permutations",":","List","[","List","[","int","]","]","p","x","n","list","of","list","of","integer",".","p","is","the","permutation","index","and","n","is","the","number","of","sites",".","cutoff",":","float","cutoff","used","for","pooling","neighbors",".","Grtol",":","float","(","default","0.0",")","relative","tolerance","in","distance","for","forming","an","edge","in","graph","Gatol",":","float","(","default","0.01",")","absolute","tolerance","in","distance","for","forming","an","edge","in","graph","rtol",":","float","(","default","0.01",")","relative","tolerance","in","rmsd","in","distance","for","graph","matching","atol",":","float","(","default","0.0",")","absolute","tolerance","in","rmsd","in","distance","for","graph","matching","tol",":","float","(","default","0.01",")","maximum","tolerance","of","position","RMSD","to","decide","whether","two","environment","are","the","same","grtol",":","float","(","default","0.01",")","tolerance","for","deciding","symmetric","nodes"]
code: def __init__(
      self,
      pos: np.ndarray,
      sitetypes: List[str],
      env2config: List[int],
      permutations: List[List[int]],
      cutoff: float = 6.00,
      Grtol: float = 0.0,
      Gatol: float = 0.01,
      rtol: float = 0.01,
      atol: float = 0.0,
      tol: float = 0.01,
      grtol: float = 1e-3,
  ):
      """
      Initialize site environment
  
      This class contains local site environment information. This is used
      to find neighbor list in the datum.
  
      Parameters
      ----------
      pos : np.ndarray
          n x 3 list or numpy array of (non-scaled) positions. n is the
          number of atom.
      sitetypes : List[str]
          n list of string. String must be S or A followed by a
          number. S indicates a spectator sites and A indicates a active
          sites.
      env2config: List[int]
          A particular permutation of the neighbors around an active
          site. These indexes will be used for lattice transformation.
      permutations : List[List[int]]
          p x n list of list of integer. p is the permutation
          index and n is the number of sites.
      cutoff : float
          cutoff used for pooling neighbors.
      Grtol : float (default 0.0)
          relative tolerance in distance for forming an edge in graph
      Gatol : float (default 0.01)
          absolute tolerance in distance for forming an edge in graph
      rtol : float (default 0.01)
          relative tolerance in rmsd in distance for graph matching
      atol : float (default 0.0)
          absolute tolerance in rmsd in distance for graph matching
      tol : float (default 0.01)
          maximum tolerance of position RMSD to decide whether two
          environment are the same
      grtol : float (default 0.01)
          tolerance for deciding symmetric nodes
      """
      try:
          import networkx.algorithms.isomorphism as iso
      except:
          raise ImportError(
              "This class requires networkx to be installed."
          )
      self.pos = pos
      self.sitetypes = sitetypes
      self.activesiteidx = [
          i for i, s in enumerate(self.sitetypes) if "A" in s
      ]
      self.formula: DefaultDict[str, int] = defaultdict(int)
      for s in sitetypes:
          self.formula[s] += 1
      self.permutations = permutations
      self.env2config = env2config
      self.cutoff = cutoff
      # Set up site environment matcher
      self.tol = tol
      # Graphical option
      self.Grtol = Grtol
      self.Gatol = Gatol
      # tolerance for grouping nodes
      self.grtol = grtol
      # determine minimum distance between sitetypes.
      # This is used to determine the existence of an edge
      dists = squareform(pdist(pos))
      mindists = defaultdict(list)
      for i, row in enumerate(dists):
          row_dists = defaultdict(list)
          for j in range(0, len(sitetypes)):
              if i == j:
                  continue
              # Sort by bond
              row_dists[frozenset((sitetypes[i], sitetypes[j]))].append(
                  dists[i, j]
              )
          for pair in row_dists:
              mindists[pair].append(np.min(row_dists[pair]))
      # You want to maximize this in order to make sure every node gets an edge
      self.mindists = {}
      for pair in mindists:
          self.mindists[pair] = np.max(mindists[pair])
      # construct graph
      self.G = self._construct_graph(pos, sitetypes)
      # matcher options
      self._nm = iso.categorical_node_match("n", "")
      self._em = iso.numerical_edge_match("d", 0, rtol, 0)
  
imports: import numpy
  import logging
  from deepchem.feat import MaterialStructureFeaturizer
  from collections import defaultdict
  from typing import List, Dict, Tuple, DefaultDict, Any
  from deepchem.utils.typing import PymatgenStructure
  from deepchem.feat.graph_data import GraphData
  from scipy.spatial.distance import pdist, squareform, cdist
  from scipy.spatial.transform import Rotation
label_desc: Use image node_id 1 to create a new _SiteEnvironment object from inherited base classes: object with example: obj = _SiteEnvironment(pos, sitetypes, env2config, permutations, cutoff, Grtol, Gatol, rtol, atol, tol, grtol)