In the symmetric inverse semigroup, $I_X$, if $|X| = n$, show that
$$|I_X| = \sum_{r=0}^n \binom{n}{r}^2 r!$$
This is a question form Howie's book on semigroup theory, unfortunately there isn't a solution to this question and I have no idea how to do it. Any help would be much appreciated.