You’re looking for the multivariate version of the formula of Faa di Bruno.
Addendum: As the OP notes, the version in Wikipedia is not in sufficient generality, since it takes $f:\mathbb R\to\mathbb R$. For a version that allows $f$ to depend on more than one variable, see for example the article: