def METHOD_NAME(string, use_cores=True, thresh=1.0e-4):
    """
    Creates an Xr object from a string representation.
    Args:
        string (str): string representation of an Xr object.
        use_cores (bool): use core positions and discard shell
                positions if set to True (default). Otherwise,
                use shell positions and discard core positions.
        thresh (float): relative threshold for consistency check
                between cell parameters (lengths and angles) from
                header information and cell vectors, respectively.
    Returns:
        xr (Xr): Xr object corresponding to the input
                string representation.
    """
    lines = string.split("\n")
    tokens = lines[0].split()
    lengths = [float(tokens[i]) for i in range(1, len(tokens))]
    tokens = lines[1].split()
    angles = [float(i) for i in tokens[0:3]]
    tokens = lines[2].split()
    n_sites = int(tokens[0])
    mat = np.zeros((3, 3), dtype=float)
    for i in range(3):
        tokens = lines[4 + n_sites + i].split()
        tokens_2 = lines[4 + n_sites + i + 3].split()
        for j, item in enumerate(tokens):
            if item != tokens_2[j]:
                raise RuntimeError("expected both matrices to be the same in xr file")
        mat[i] = np.array([float(w) for w in tokens])
    lat = Lattice(mat)
    if (
        fabs(lat.a - lengths[0]) / fabs(lat.a) > thresh
        or fabs(lat.b - lengths[1]) / fabs(lat.b) > thresh
        or fabs(lat.c - lengths[2]) / fabs(lat.c) > thresh
        or fabs(lat.alpha - angles[0]) / fabs(lat.alpha) > thresh
        or fabs(lat.beta - angles[1]) / fabs(lat.beta) > thresh
        or fabs(lat.gamma - angles[2]) / fabs(lat.gamma) > thresh
    ):
        raise RuntimeError(
            f"cell parameters in header ({lengths}, {angles}) are not consistent with Cartesian "
            f"lattice vectors ({lat.abc}, {lat.angles})"
        )
    # Ignore line w/ index 3.
    sp = []
    coords = []
    for j in range(n_sites):
        m = re.match(
            r"\d+\s+(\w+)\s+([0-9\-\.]+)\s+([0-9\-\.]+)\s+([0-9\-\.]+)",
            lines[4 + j].strip(),
        )
        if m:
            tmp_sp = m.group(1)
            if use_cores and tmp_sp[len(tmp_sp) - 2 :] == "_s":
                continue
            if not use_cores and tmp_sp[len(tmp_sp) - 2 :] == "_c":
                continue
            if tmp_sp[len(tmp_sp) - 2] == "_":
                sp.append(tmp_sp[0 : len(tmp_sp) - 2])
            else:
                sp.append(tmp_sp)
            coords.append([float(m.group(i)) for i in range(2, 5)])
    return Xr(Structure(lat, sp, coords, coords_are_cartesian=True))