def _needs_init_layer(grouped_settings: dict[InitObsSetting, list[InitObsSetting]]) -> bool:
    """Helper function to go through init_states and determine if any of them need an
    initialization layer of single-qubit gates."""
    for max_setting in grouped_settings.keys():
        if any(st is not value.KET_ZERO for _, st in max_setting.init_state):
            return True
    return False
Helper function to go through init_states and determine if any of them need an
    initialization layer of single-qubit gates.
cirq-core/cirq/work/observable_measurement.py