def contrib_class_resolver(cirq_type: str):
    """Extend cirq's JSON API with resolvers for cirq contrib classes."""
    from cirq.contrib.acquaintance import SwapPermutationGate
    from cirq.contrib.bayesian_network import BayesianNetworkGate
    from cirq.contrib.quantum_volume import QuantumVolumeResult

    classes = [BayesianNetworkGate, QuantumVolumeResult, SwapPermutationGate]
    d = {cls.__name__: cls for cls in classes}
    return d.get(cirq_type, None)
Extend cirq's JSON API with resolvers for cirq contrib classes.
cirq-core/cirq/contrib/json.py