@classmethod
def serialize(cls, value):
    """
        Serialize a type to GraphSON2.

        e.g {'@type': 'gx:Duration', '@value': 'P2DT4H'}

        :param value: The python object to serialize.
        """
    serializer = cls.get_serializer(value)
    if not serializer:
        return value
    value = serializer.serialize(value)
    out = {cls.TYPE_KEY: serializer.graphson_type}
    if value is not None:
        out[cls.VALUE_KEY] = value
    return out
