def _apply_unitary_from_matrix_strat(
    val: np.ndarray, args: ApplyMixtureArgs, is_density_matrix: bool
) -> np.ndarray | None:
    """Used to enact mixture tuples that are given as (probability, np.ndarray)

    If `val` does not support `apply_unitary` returns None.
    """
    qid_shape = tuple(args.target_tensor.shape[i] for i in args.left_axes)
    matrix_tensor = np.reshape(val.astype(args.target_tensor.dtype), qid_shape * 2)
    linalg.targeted_left_multiply(
        matrix_tensor, args.target_tensor, args.left_axes, out=args.auxiliary_buffer0
    )

    if not is_density_matrix:
        return args.auxiliary_buffer0
    # No need to transpose as we are acting on the tensor
    # representation of matrix, so transpose is done for us.
    linalg.targeted_left_multiply(
        np.conjugate(matrix_tensor),
        args.auxiliary_buffer0,
        cast(tuple[int], args.right_axes),
        out=args.target_tensor,
    )
    return args.target_tensor
Used to enact mixture tuples that are given as (probability, np.ndarray)

    If `val` does not support `apply_unitary` returns None.
    
cirq-core/cirq/protocols/apply_mixture_protocol.py