def to_dict(c: Type[T], x: Any) -> dict:
    """Convert `x` of class `c` to dict. `c` should have the method `to_dict`."""
    assert isinstance(x, c)
    return cast(Any, x).to_dict()
Convert `x` of class `c` to dict. `c` should have the method `to_dict`.
preprocess/src/data_types/utils.py