"""Dictionary representation of chain.
        Expects `Chain._chain_type` property to be implemented and for memory to be
            null.
        Args:
            **kwargs: Keyword arguments passed to default `pydantic.BaseModel.dict`
                method.
        Returns:
            A dictionary representation of the chain.
        Example:
            .. code-block:: python
                chain.dict(exclude_unset=True)
                # -> {"_type": "foo", "verbose": False, ...}
        """
        if self.memory is not None:
            raise ValueError("Saving of memory is not yet supported.")
        _dict = super().dict(**kwargs)
        _dict["_type"] = self._chain_type
        return _dict
[docs]    def save(self, file_path: Union[Path, str]) -> None:
        """Save the chain.
        Expects `Chain._chain_type` property to be implemented and for memory to be
            null.
        Args:
            file_path: Path to file to save the chain to.
        Example:
            .. code-block:: python
                chain.save(file_path="path/chain.yaml")
        """
        # Convert file to Path object.
        if isinstance(file_path, str):
            save_path = Path(file_path)
        else:
            save_path = file_path
        directory_path = save_path.parent
        directory_path.mkdir(parents=True, exist_ok=True)
        # Fetch dictionary to save
        chain_dict = self.dict()
        if save_path.suffix == ".json":
            with open(file_path, "w") as f:
                json.dump(chain_dict, f, indent=4)
        elif save_path.suffix == ".yaml":
            with open(file_path, "w") as f: