Create matrix by applying function to the mulitplication of to vectors

Hello,

I was wondering what the fastest way to compute the following is :
Suppose two vectors (v1,v2) of dim (bs,n,c), (bs,m,c):

matrix = torch.zeros((bs,n,m))
For i in range(n):
     For j in range(m):
          matrix[:,i,j] = foo(v1[:,i,:],v2[:,j:,])

Thank you in advance