How to load a pretrained custom model using `from_pretrained`

The reason for this error is that the class definition is missing the config_class

class CustomModel(PreTrainedModel):
    config_class = CustomConfig

    def __init__(self, config, ...
    ...

There is an example in the guide in the original question.