code: def _get_SiteEnvironments(
      struct: PymatgenStructure,
      cutoff: float,
      PBC: np.typing.ArrayLike,
      get_permutations: bool = True,
      eigen_tol: float = 1e-5,
  ) -> List[Dict[str, Any]]:
      """
      Used to extract information about both primitive cells and data points.
      Extract local environments from Structure object by calculating neighbors
      based on gaussian distance. For primitive cell, Different permutations of the
      neighbors are calculated and will be later will mapped for data point in the
      _SiteEnvironment.get_mapping() function.
      site types ,
  
      Parameters
      ----------
      struct: PymatgenStructure
          Pymatgen Structure object of the primitive cell used for calculating
          neighbors from lattice transformations.It also requires site_properties
          attribute with "Sitetypes"(Active or spectator site).
      cutoff : float
          cutoff distance in angstrom for collecting local
          environment.
      pbc : ArrayLike
          Periodic boundary condition
      get_permutations : bool (default True)
          Whether to find permuted neighbor list or not.
      eigen_tol : float (default 1e-5)
          Tolerance for eigenanalysis of point group analysis in
          pymatgen.
  
      Returns
      ------
      site_envs : List[Dict[str, Any]]
          list of local_env class
      """
      try:
          from pymatgen.core import Molecule
          from pymatgen.symmetry.analyzer import PointGroupAnalyzer
      except:
          raise ImportError(
              "This class requires pymatgen to be installed."
          )
  
      pbc = np.array(PBC)
      structure = struct
      neighbors = structure.get_all_neighbors(
          cutoff, include_index=True
      )
      symbols = structure.species
      site_idxs = [
          i
          for i, sitetype in enumerate(
              structure.site_properties["SiteTypes"]
          )
          if sitetype == "A1"
      ]
      site_sym_map = {}
      sym_site_map = {}
      for i, new_ele in enumerate(structure.species):
          sym_site_map[new_ele] = structure.site_properties[
              "SiteTypes"
          ][i]
          site_sym_map[
              structure.site_properties["SiteTypes"][i]
          ] = new_ele
  
      site_envs = []
      for site_idx in site_idxs:
          local_env_sym = [symbols[site_idx]]
          local_env_xyz = [structure[site_idx].coords]
          local_env_dist = [0.0]
          local_env_sitemap = [site_idx]
          for n in neighbors[site_idx]:
              # if PBC condition is fulfilled..
              c = np.around(n[0].frac_coords, 10)
              withinPBC = np.logical_and(0 <= c, c < 1)
              if np.all(withinPBC[~pbc]):
                  local_env_xyz.append(n[0].coords)
                  local_env_sym.append(n[0].specie)
                  local_env_dist.append(n[1])
                  local_env_sitemap.append(n[2])
          local_env_pos = np.subtract(
              local_env_xyz, np.mean(local_env_xyz, 0)
          )
  
          perm = []
          if get_permutations:
              finder = PointGroupAnalyzer(
                  Molecule(local_env_sym, local_env_pos),  # type: ignore
                  eigen_tolerance=eigen_tol,
              )
              pg = finder.get_pointgroup()
              for i, op in enumerate(pg):
                  newpos = op.operate_multi(local_env_pos)
                  perm.append(
                      np.argmin(
                          cdist(local_env_pos, newpos), axis=1
                      ).tolist()
                  )
  
          site_env = {
              "pos": local_env_pos,
              "sitetypes": [sym_site_map[s] for s in local_env_sym],
              "env2config": local_env_sitemap,
              "permutations": perm,
              "dist": local_env_dist,
          }
          site_envs.append(site_env)
      return site_envs
  
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 2 for calling a global function with example usage: _get_SiteEnvironments(struct, cutoff, PBC, get_permutations, eigen_tol) and returns: site_envs