"""Save the deanonymizer mapping to a JSON or YAML file.
        Args:
            file_path: Path to file to save the mapping to.
        Example:
        .. code-block:: python
            anonymizer.save_deanonymizer_mapping(file_path="path/mapping.json")
        """
        save_path = Path(file_path)
        if save_path.suffix not in [".json", ".yaml"]:
            raise ValueError(f"{save_path} must have an extension of .json or .yaml")
        # Make sure parent directories exist
        save_path.parent.mkdir(parents=True, exist_ok=True)
        if save_path.suffix == ".json":
            with open(save_path, "w") as f:
                json.dump(self.deanonymizer_mapping, f, indent=2)
        elif save_path.suffix == ".yaml":
            with open(save_path, "w") as f:
                yaml.dump(self.deanonymizer_mapping, f, default_flow_style=False)
[docs]    def load_deanonymizer_mapping(self, file_path: Union[Path, str]) -> None:
        """Load the deanonymizer mapping from a JSON or YAML file.
        Args:
            file_path: Path to file to load the mapping from.
        Example:
        .. code-block:: python
            anonymizer.load_deanonymizer_mapping(file_path="path/mapping.json")
        """
        load_path = Path(file_path)
        if load_path.suffix not in [".json", ".yaml"]:
            raise ValueError(f"{load_path} must have an extension of .json or .yaml")
        if load_path.suffix == ".json":
            with open(load_path, "r") as f:
                loaded_mapping = json.load(f)
        elif load_path.suffix == ".yaml":