def wigner_d_transform_analysis_vectorized(f, wd_flat, idxs):
    """ computes the wigner transform analysis in a vectorized way
    returns the flattened blocks of f_hat as a single vector

    f: the input signal, shape (2b, 2b, 2b) axes m, beta, n.
    wd_flat: the flattened weighted wigner d functions, shape (num_spectral, 2b), axes (l*m*n, beta)
    idxs: the array of indices containing all analysis blocks
    """
    f_trans = f.transpose([0, 2, 1])                # shape 2b, 2b, 2b, axes m, n, beta
    f_trans_flat = f_trans.reshape(-1, f.shape[1])  # shape 4b^2, 2b, axes m*n, beta
    f_i = f_trans_flat[idxs]                        # shape num_spectral, 2b, axes l*m*n, beta
    prod = f_i * wd_flat                            # shape num_spectral, 2b, axes l*m*n, beta
    result = prod.sum(axis=1)                       # shape num_spectral, axes l*m*n
    return result