def slice_for_qubits_equal_to(target_qubit_axes: Sequence[int],
                              little_endian_qureg_value: int,
                              *,  # Forces keyword args.
                              num_qubits: int = None
                              ) -> Tuple[Union[slice, int, 'ellipsis'], ...]:
    """Returns an index corresponding to a desired subset of an np.ndarray.

    It is assumed that the np.ndarray's shape is of the form (2, 2, 2, ..., 2).

    Example:

        ```python
        # A '4 qubit' tensor with values from 0 to 15.
        r = np.array(range(16)).reshape((2,) * 4)

        # We want to index into the subset where qubit #1 and qubit #3 are ON.
        s = cirq.slice_for_qubits_equal_to([1, 3], 0b11)
        print(s)
        # (slice(None, None, None), 1, slice(None, None, None), 1, Ellipsis)

        # Get that subset. It corresponds to numbers of the form 0b*1*1.
        # where here '*' indicates any possible value.
        print(r[s])
        # [[ 5  7]
        #  [13 15]]
        ```

    Args:
        target_qubit_axes: The qubits that are specified by the index bits. All
            other axes of the slice are unconstrained.
        little_endian_qureg_value: An integer whose bits specify what value is
            desired for of the target qubits. The integer is little endian
            w.r.t. the target quit axes, meaning the low bit of the integer
            determines the desired value of the first targeted qubit, and so
            forth with the k'th targeted qubit's value set to
            bool(qureg_value & (1 << k)).
        num_qubits: If specified the slices will extend all the way up to
            this number of qubits, otherwise if it is None, the final element
            return will be Ellipsis. Optional and defaults to using Ellipsis.

    Returns:
        An index object that will slice out a mutable view of the desired subset
        of a tensor.
    """
    n = num_qubits if num_qubits is not None else (
        max(target_qubit_axes) if target_qubit_axes else -1)
    result = [slice(None)] * (n + 2 * (
            num_qubits is None))  # type: List[Union[slice, int, ellipsis]]
    for k, axis in enumerate(target_qubit_axes):
        result[axis] = (little_endian_qureg_value >> k) & 1
    if num_qubits is None:
        result[-1] = Ellipsis
    return tuple(result)
def slice_for_qubits_equal_to ( target_qubit_axes : Sequence [ int ] , little_endian_qureg_value : int , * , num_qubits : int = None ) -> Tuple [ Union [ slice , int , 'ellipsis' ] , ... ] : n = num_qubits if num_qubits is not None else ( max ( target_qubit_axes ) if target_qubit_axes else - 1 ) result = [ slice ( None ) ] * ( n + 2 * ( num_qubits is None ) ) for k , axis in enumerate ( target_qubit_axes ) : result [ axis ] = ( little_endian_qureg_value >> k ) & 1 if num_qubits is None : result [ - 1 ] = Ellipsis return tuple ( result )
Returns an index corresponding to a desired subset of an np.ndarray.

    It is assumed that the np.ndarray's shape is of the form (2, 2, 2, ..., 2).

    Example:

        ```python
        # A '4 qubit' tensor with values from 0 to 15.
        r = np.array(range(16)).reshape((2,) * 4)

        # We want to index into the subset where qubit #1 and qubit #3 are ON.
        s = cirq.slice_for_qubits_equal_to([1, 3], 0b11)
        print(s)
        # (slice(None, None, None), 1, slice(None, None, None), 1, Ellipsis)

        # Get that subset. It corresponds to numbers of the form 0b*1*1.
        # where here '*' indicates any possible value.
        print(r[s])
        # [[ 5  7]
        #  [13 15]]
        ```

    Args:
        target_qubit_axes: The qubits that are specified by the index bits. All
            other axes of the slice are unconstrained.
        little_endian_qureg_value: An integer whose bits specify what value is
            desired for of the target qubits. The integer is little endian
            w.r.t. the target quit axes, meaning the low bit of the integer
            determines the desired value of the first targeted qubit, and so
            forth with the k'th targeted qubit's value set to
            bool(qureg_value & (1 << k)).
        num_qubits: If specified the slices will extend all the way up to
            this number of qubits, otherwise if it is None, the final element
            return will be Ellipsis. Optional and defaults to using Ellipsis.

    Returns:
        An index object that will slice out a mutable view of the desired subset
        of a tensor.