Say we have the composition $f(g(x_1,x_2,x_3),x_4)$, where $f:\mathbb R^2 \rightarrow \mathbb R$ and $g:\mathbb R^3 \rightarrow \mathbb R$.
Is this composition even valid?
I mean, in general we have $$ \tag 1 F:\mathbb R^n \rightarrow \mathbb R^p\\ G:\mathbb R^m \rightarrow \mathbb R^n $$ So the composition is $F\circ G:\mathbb R^m \rightarrow \mathbb R^p$.
But in our case, for $f$ we have $n=2$ and $p=1$, i.e. $f:\mathbb R^2 \rightarrow \mathbb R$. And for $g$ we have $m=3$ and $n=1$, i.e. $g:\mathbb R^3 \rightarrow \mathbb R$. So this doesn't match the definition in $(1)$, why?
Here you have $\Bbb R^4\to\Bbb R^2\to \Bbb R$, where the first step is not $g$, but $(g,\operatorname{id})\colon (x_1,x_2,x_3,x_4)\mapsto (g(x_1,x_2,x_3),x_4)$.