code: def get_crystal_field_spin(self, coordination: str = "oct",
                                 spin_config: str = "high"):
          
          if coordination not in ("oct", "tet") or \
                  spin_config not in ("high", "low"):
              raise ValueError("Invalid coordination or spin config.")
          elec = self.full_electronic_structure
          if len(elec) < 4 or elec[-1][1] != "s" or elec[-2][1] != "d":
              raise AttributeError(
                  "Invalid element {} for crystal field calculation.".format(
                      self.symbol))
          nelectrons = elec[-1][2] + elec[-2][2] - self.oxi_state
          if nelectrons < 0 or nelectrons > 10:
              raise AttributeError(
                  "Invalid oxidation state {} for element {}"
                  .format(self.oxi_state, self.symbol))
          if spin_config == "high":
              return nelectrons if nelectrons <= 5 else 10 - nelectrons
          elif spin_config == "low":
              if coordination == "oct":
                  if nelectrons <= 3:
                      return nelectrons
                  elif nelectrons <= 6:
                      return 6 - nelectrons
                  elif nelectrons <= 8:
                      return nelectrons - 6
                  else:
                      return 10 - nelectrons
              elif coordination == "tet":
                  if nelectrons <= 2:
                      return nelectrons
                  elif nelectrons <= 4:
                      return 4 - nelectrons
                  elif nelectrons <= 7:
                      return nelectrons - 4
                  else:
                      return 10 - nelectrons
docs: Calculate the crystal field spin based on coordination and spin
          configuration. Only works for transition metal species.
  
          Args:
              coordination (str): Only oct and tet are supported at the moment.
              spin_config (str): Supported keywords are "high" or "low".
  
          Returns:
              Crystal field spin in Bohr magneton.
  
          Raises:
              AttributeError if species is not a valid transition metal or has
              an invalid oxidation state.
              ValueError if invalid coordination or spin_config.