should be doable if you make combinations of indexes instead (i.e. of elements from arange(K,dtype=int64)), and use the resulting tensor for “advanced indexing” on X. so you’ll get value pairs and prod(dim=x) reduction will finally yield the desired output.