code: def _estimate_spin_state(species, motif, known_magmom):
          
          mu_so_high = JahnTellerAnalyzer.mu_so(species, motif=motif, spin_state="high")
          mu_so_low = JahnTellerAnalyzer.mu_so(species, motif=motif, spin_state="low")
          if mu_so_high == mu_so_low:
              return "undefined"  # undefined or only one spin state possible
          elif mu_so_high is None:
              return "low"
          elif mu_so_low is None:
              return "high"
          else:
              diff = mu_so_high - mu_so_low
              # WARNING! this heuristic has not been robustly tested or benchmarked
              # using 'diff*0.25' as arbitrary measure, if known magmom is
              # too far away from expected value, we don't try to classify it
              if known_magmom > mu_so_high or abs(mu_so_high - known_magmom) < diff * 0.25:
                  return "high"
              elif known_magmom < mu_so_low or abs(mu_so_low - known_magmom) < diff * 0.25:
                  return "low"
              else:
                  return "unknown"
docs: Simple heuristic to estimate spin state. If magnetic moment
          is sufficiently close to that predicted for a given spin state,
          we assign it that state. If we only have data for one spin
          state then that's the one we use (e.g. we assume all tetrahedral
          complexes are high-spin, since this is typically the case).
  
          :param species: str or Species
          :param motif (str): "oct" or "tet"
          :param known_magmom (float):
          :return: