def METHOD_NAME(self, p: pathlib.Path) -> pathlib.Path:
    if not p.is_absolute():
        return p
    if self._base_path:
        return _relative_to(p, self._base_path)
    if self._no_base_path_inference:
        return p
    if not self._inferred_base_path:
        self._inferred_base_path = self._auto_infer_base_path(p)
    if self._inferred_base_path:
        return _relative_to(p, self._inferred_base_path)
    return p