By number of sales it's a wash between it and the S. Which are both low volume, high margin, luxury vehicles. Their high volume vehicles, the 3 and the Y drastically out-sell them naturally.
However the X and the S have very high margins in all configurations so they bring in an outsized amount of profit given their share of sales.
That said the margins on the Model 3/Y are nothing to snuff at and are superior to any other mass market vehicle.