(7) 5 Hint: From the condition, we know that $1+\cos \theta \in[1,2]$, then $2 \leqslant x \leqslant 4$, thus
$$
f(x)=x-1+2|x-3| .
$$

When $2 \leqslant x \leqslant 3$,
$$
f(x)=x-1+2|x-3|=5-x,
$$

the maximum value at this time is 3;
When $3 \leqslant x \leqslant 4$,
$$
f(x)=x-1+2|x-3|=3 x-7,
$$

the maximum value at this time is 5.
In summary, $f(x)$ reaches its maximum value of 5 at $x=4$.
(7) If the real number $x$ satisfies $\log _{2} x=1+\cos \theta$, where $\theta \in\left[-\frac{\pi}{2}, 0\right]$, then the maximum value of the function $f(x)=|x-1|+2|x-3|$ is $\qquad$ .