  The main aim of this article is to compute all the moments of the number of
$p^\ell$-torsion elements in some type of nite abelian groups. The averages
involved in these moments are those de ned for the Cohen-Lenstra heuristics for
class groups and their adaptation for Tate-Shafarevich groups. In particular,
we prove that the heuristic model for Tate-Shafarevich groups is compatible
with the recent conjecture of Poonen and Rains about the moments of the orders
of $p$-Selmer groups of elliptic curves. For our purpose, we are led to de ne
certain polynomials indexed by integer partitions and to study them in a
combinatorial way. Moreover, from our probabilistic model, we derive
combinatorial identities, some of which appearing to be new, the others being
related to the theory of symmetric functions. In some sense, our method
therefore gives for these identities a somehow natural algebraic context.
