The idea of a CPU is a bit of an abstraction now, and this started with hyperthreading (late 90's) and then the Intel Core (early 00's) series. Before then you definitely had multiple-CPU systems but they were all multiple-physical-CPU.
But with hyperthreading and multiple-core single CPUs, the physical # of CPUs is different than the logical # of CPUs the running code on the CPUs sees.
You have 2 physical CPUs as in "thing with heatsink plugged into your motherboard"
Core(s) per socket: 20
Each physical CPU has 20 cores, which look and mostly work like independent CPUs to Linux. Cores share at least the same L3 cache, probably L2 cache, and probably have their own L1 cache - so not quite as peformant as individual sockets with their own L3/L2/L1 but nearly there.
Since that's each socket, you have 2 * 20 = 40.
Thread(s) per core: 2
Each core has 2 SMT threads, which are implemented by your CPU's microarchitecture to basically look mostly like independent CPUs to Linux
They're not going to be anywhere as fast as real independent cores.
Threads on the microarchitecture try to grab currently unused pipeline stages from cores but might have to end up waiting if busy--and CPUs already try to keep themselves very busy, so again 2 threads on 2 cores is nowhere near equivalent to 4 cores, but it is something that can make code run a bit faster.
Note that Spectre and similar vulnerabilities are much more possible across threads than cores or sockets because core resources are shared.
Anyway, since that's per core, and also per socket, that's 2 * 20 * 2, which gives you: