def METHOD_NAME(
    measurementprocess: StateMeasurement, state: TensorLike, is_state_batched: bool = False
) -> TensorLike:
    """Apply a measurement to state when the measurement process has an observable with diagonalizing gates.
    Args:
        measurementprocess (StateMeasurement): measurement to apply to the state
        state (TensorLike): state to apply the measurement to
        is_state_batched (bool): whether the state is batched or not
    Returns:
        TensorLike: the result of the measurement
    """
    for op in measurementprocess.diagonalizing_gates():
        state = apply_operation(op, state, is_state_batched=is_state_batched)
    total_indices = len(state.shape) - is_state_batched
    wires = Wires(range(total_indices))
    flattened_state = (
        math.reshape(state, (state.shape[0], -1)) if is_state_batched else math.flatten(state)
    )
    return measurementprocess.process_state(flattened_state, wires)