Returns the probabilities for a measurement on the given indices.

def _probs(state: np.ndarray, indices: List[int],
           num_qubits: int) -> List[float]:
    """Returns the probabilities for a measurement on the given indices."""
    # Tensor of squared amplitudes, shaped a rank [2, 2, .., 2] tensor.
    tensor = np.reshape(state, [2] * num_qubits)

    # Calculate the probabilities for measuring the particular results.
    probs = [
        np.linalg.norm(
                tensor[linalg.slice_for_qubits_equal_to(indices, b)]) ** 2
        for b in range(2 ** len(indices))]

    # To deal with rounding issues, ensure that the probabilities sum to 1.
    probs /= sum(probs) # type: ignore
    return probs