This is an incredibly dense matrix. Are you sure you want this in your variational form?
I would compute
a=dolfinx.fem.petsc.assemble_vector(dolfinx.fem.form(u*ds(1)))
b=dolfinx.fem.petsc.assemble_vector(dolfinx.fem.form(v*ds(1)))
Then find the nonzero entries of these two vectors, (hopefully there are many).
One can then in turn add these to an assembled matrix A with setvalueslocal
as for instance shown in: