def METHOD_NAME(cls, v, values, **kwargs):
    if "datasets" not in values:
        raise ValueError("datasets not defined")
    for dataset_id in values["datasets"]:
        if dataset_id == v.topic.source_dataset:
            return v
    raise ValueError(
        f"Emulator topic {v.topic.id} has undefined dataset {v.topic.source_dataset}"
    )