def auto_serialize(value):
    """
    Serializes a value for storage in the execution cache.

    Args:
        value: the value to serialize

    Returns:
        The serialized value.
    """
    if isinstance(value, fo.Sample):
        return focu._make_sample_dict(value)
    if isinstance(value, etas.Serializable):
        return value.serialize()
    elif hasattr(value, "to_dict"):
        return value.to_dict()
    elif hasattr(value, "to_json"):
        return value.to_json()
    elif isinstance(value, dict):
        return {str(k): auto_serialize(v) for k, v in value.items()}
    elif isinstance(value, list):
        return [auto_serialize(v) for v in value]
    elif isinstance(value, tuple):
        return {
            "_cls": "tuple",
            "values": [auto_serialize(v) for v in value],
        }
    elif isinstance(value, set):
        return {
            "_cls": "set",
            "values": [auto_serialize(v) for v in value],
        }
    elif isinstance(value, datetime):
        return {"_cls": "datetime", "value": value.isoformat()}
    elif isinstance(value, date):
        return {"_cls": "date", "value": value.isoformat()}
    elif isinstance(value, (int, float, str, bool)) or value is None:
        return value
    elif isinstance(value, np.ndarray):
        return value.tolist()
    elif isinstance(value, np.generic):
        return value.item()
    raise TypeError(f"Cannot serialize value of type {type(value)}: {value}")

    Serializes a value for storage in the execution cache.

    Args:
        value: the value to serialize

    Returns:
        The serialized value.
    
fiftyone/operators/cache/serialization.py