code: def get_chemical_formula(atoms, mode='metal'):
      
      try:
          return atoms.get_chemical_formula(mode=mode)
      except ValueError:
          return atoms.get_chemical_formula(mode='hill')
docs: Compatibility function, return mode=metal, when
      available, mode=hill, when not (ASE <= 3.13)