def _lazy_resolver(dict_factory: Callable[[], dict[str, ObjectFactory]]) -> JsonResolver:
    """A lazy JsonResolver based on a dict_factory.

    It only calls dict_factory when the first key is accessed.

    Args:
        dict_factory: a callable that generates an instance of the
          class resolution map - it is assumed to be cached
    """

    def json_resolver(cirq_type: str) -> ObjectFactory | None:
        return dict_factory().get(cirq_type, None)

    return json_resolver
A lazy JsonResolver based on a dict_factory.

    It only calls dict_factory when the first key is accessed.

    Args:
        dict_factory: a callable that generates an instance of the
          class resolution map - it is assumed to be cached
    
cirq-core/cirq/protocols/json_serialization.py