Replacing $\mathcal{X}$ by $\mathcal{Z}$, we may and do assume that $f$ is scheme theoretically dominant, and also that $\mathcal{X}$ is irreducible. By the upper semi-continuity of fibre dimensions (Lemma \ref{lemma-relative-dimension-is-semi-continuous} (1)), it suffices to prove that the equality $\dim_t( \mathcal{T}_{f(t)}) =\dim \mathcal{T}  - \dim \mathcal{Z}$ holds for $t$ lying in some non-empty open substack of $\mathcal{T}$. For this reason, in the argument we are always free to replace $\mathcal{T}$ by a non-empty open substack. \medskip\noindent Let $T' \to \mathcal{T}$ be a smooth surjective morphism whose source is a scheme, and let $T$ be a non-empty quasi-compact open subset of $T'$.  Since $\mathcal{Y}$ is quasi-separated, we find that $T \to  \mathcal{Y}$ is quasi-compact (by Morphisms of Stacks, Lemma \ref{stacks-morphisms-lemma-quasi-compact-permanence}, applied to the morphisms $T \to \mathcal{Y} \to \Spec \mathbf{Z}$). Thus, if we replace $\mathcal{T}$ by the image of $T$ in $\mathcal{T}$, then we may assume (appealing to Morphisms of Stacks, Lemma \ref{stacks-morphisms-lemma-surjection-from-quasi-compact} that the morphism $f:\mathcal{T} \to \mathcal{X}$ is quasi-compact. \medskip\noindent If we choose a smooth surjection $U \to \mathcal{X}$ with $U$ a scheme, then Lemma \ref{lemma-map-of-components} ensures that we may find an irreducible open subset $V$ of $U$ such that $V \to \mathcal{X}$ is smooth and scheme-theoretically dominant. Since scheme-theoretic dominance for quasi-compact morphisms is preserved by flat base-change, the base-change $\mathcal{T} \times_{\mathcal{X}} V \to V$ of the scheme-theoretically dominant morphism $f$ is again scheme-theoretically dominant.   We let $Z$ denote a scheme admitting a smooth surjection onto this fibre product; then $Z \to \mathcal{T} \times_{\mathcal{X}} V \to V$ is again scheme-theoretically dominant. Thus we may find an irreducible component $C$ of $Z$ which scheme-theoretically dominates $V$. Since the composite  $Z \to \mathcal{T}\times_{\mathcal{X}} V \to \mathcal{T}$ is smooth, and since $\mathcal{T}$ is irreducible, Lemma \ref{lemma-map-of-components} shows that any irreducible component of the source has dense image in $|\mathcal{T}|$. We now replace $C$ by a non-empty open subset $W$ which is disjoint from every other irreducible component of $Z$, and then replace $\mathcal{T}$ and $\mathcal{X}$ by the images of $W$ and $V$ (and apply Lemma \ref{lemma-irreducible-implies-equidimensional} to see that this doesn't change the dimension of either $\mathcal{T}$ or $\mathcal{X}$). If we let $\mathcal{W}$ denote the image of the morphism $W \to \mathcal{T}\times_{\mathcal{X}} V$, then $\mathcal{W}$ is open in $\mathcal{T}\times_{\mathcal{X}} V$ (since the morphism $W \to \mathcal{T}\times_{\mathcal{X}} V$ is smooth), and is irreducible (being the image of an irreducible scheme).  Thus we end up with a commutative diagram $$ \xymatrix{ W \ar[dr] \ar[r]  & \mathcal{W} \ar[r] \ar[d] & V \ar[d] \\ & \mathcal{T} \ar[r] & \mathcal{X} } $$ in which $W$ and $V$ are schemes, the vertical arrows are smooth and surjective, the diagonal arrows and the left-hand upper horizontal arroware smooth, and the induced morphism $\mathcal{W} \to \mathcal{T}\times_{\mathcal{X}} V$ is an open immersion. Using this diagram, together with the definitions of the various dimensions involved in the statement of the lemma, we will reduce our verification of the lemma to the case of schemes, where it is known. \medskip\noindent Fix $w \in |W|$ with image $w' \in |\mathcal{W}|$, image $t \in |\mathcal{T}|$, image $v$ in $|V|$, and image $x$ in $|\mathcal{X}|$. Essentially by definition (using the fact that $\mathcal{W}$ is open in $\mathcal{T}\times_{\mathcal{X}} V$, and that the fibre of a base-change is the base-change of the fibre), we obtain the equalities $$ \dim_v V_x = \dim_{w'} \mathcal{W}_t $$ and $$ \dim_t \mathcal{T}_x = \dim_{w'} \mathcal{W}_v. $$ By Lemma \ref{lemma-behaviour-of-dimensions-wrt-smooth-morphisms} (the diagonal arrow and right-hand vertical arrow in our diagram realise $W$ and $V$ as smooth covers by schemes of the stacks $\mathcal{T}$ and $\mathcal{X}$), we find that $$ \dim_t \mathcal{T} = \dim_w W - \dim_w W_t $$ and $$ \dim_x \mathcal{X} = \dim_v V - \dim_v V_x. $$ Combining the equalities, we find that $$ \dim_t \mathcal{T}_x - \dim_t \mathcal{T} + \dim_x \mathcal{X} = \dim_{w'} \mathcal{W}_v - \dim_w W + \dim_w W_t + \dim_v V - \dim_{w'} \mathcal{W}_t $$ Since $W \to \mathcal{W}$ is a smooth surjection, the same is true if we base-change over the morphism $\Spec \kappa(v) \to V$ (thinking of $W \to \mathcal{W}$ as a morphism over $V$), and from this smooth morphism we obtain the first of the following two equalities $$ \dim_w W_v - \dim_{w'} \mathcal{W}_v = \dim_w (W_v)_{w'} = \dim_w W_{w'}; $$ the second equality follows via a direct comparison of the two fibres involved. Similarly, if we think of $W \to \mathcal{W}$ as a morphism of schemes over $\mathcal{T}$, and base-change over some representative of the point $t \in |\mathcal{T}|$, we obtain the equalities $$ \dim_w W_t - \dim_{w'} \mathcal{W}_t = \dim_w (W_t)_{w'} = \dim_w W_{w'}. $$ Putting everything together, we find that $$ \dim_t \mathcal{T}_x - \dim_t \mathcal{T} + \dim_x \mathcal{X} =  \dim_w W_v - \dim_w W + \dim_v V. $$ Our goal is to show that the left-hand side of this equality vanishes for a non-empty open subset of $t$.  As $w$ varies over a non-empty open subset of $W$, its image $t \in |\mathcal{T}|$ varies over a non-empty open subset of $|\mathcal{T}|$ (as $W \to \mathcal{T}$ is smooth). \medskip\noindent We are therefore reduced to showing that if $W\to V$ is a scheme-theoretically dominant morphism of irreducible locally Noetherian schemes that is locally of finite type, then there is a non-empty open subset of points $w\in W$ such that $\dim_w W_v =\dim_w W - \dim_v V$ (where $v$ denotes the image of $w$ in $V$). This is a standard fact, whose proof we recall for the convenience of the reader. \medskip\noindent We may replace $W$ and $V$ by their underlying reduced subschemes without altering the validity (or not) of this equation, and thus we may assume that they are in fact integral schemes. Since $\dim_w W_v$ is locally constant on $W,$ replacing $W$ by a non-empty open subset if necessary, we may assume that $\dim_w W_v$ is constant, say equal to $d$.  Choosing this open subset to be affine, we may also assume that the morphism $W\to V$ is in fact of finite type. Replacing $V$ by a non-empty open subset if necessary (and then pulling back $W$ over this open subset; the resulting pull-back is non-empty, since the flat base-change of a quasi-compact and scheme-theoretically dominant morphism remains scheme-theoretically dominant), we may furthermore assume that $W$ is flat over $V$. The morphism $W\to V$ is thus of relative dimension $d$ in the sense of Morphisms, Definition \ref{morphisms-definition-relative-dimension-d} and it follows from Morphisms, Lemma \ref{morphisms-lemma-rel-dimension-dimension} that $\dim_w(W) = \dim_v(V) + d,$ as required.