9. (16 points) Find the minimum value of $M$ such that the function
$$
f(x)=x^{2}-2 x+1
$$

for any partition of the interval $[0,4]$
$$
0=x_{0}<x_{1}<\cdots<x_{n-1}<x_{n}=4,
$$

satisfies
$$
\sum_{i=1}^{n}\left|f\left(x_{i}\right)-f\left(x_{i-1}\right)\right| \leqslant M .
$$
$$
\begin{array}{l}
=2(11-k)-\sum_{i=k+1}^{11} x_{i} \\
\leqslant 22-2 k-(11-k) x_{k+1} \\
<22-2 k-\frac{6(11-k)}{k+1} \\
<6-\frac{2(k-5)^{2}}{k+1} \leqslant 6 .
\end{array}
$$

Therefore, taking $A=\left\{P_{1}, P_{2}, \cdots, P_{k}\right\}, B=\left\{P_{k+1}\right.$, $\left.P_{k+2}, \cdots, P_{11}\right\}$ is sufficient.
Thus, $k_{\max }=11$.
II. 9. For any partition of the interval $[0,4]$
$$
0=x_{0}<x_{1}<\cdots<x_{n-1}<x_{n}=4 \text {, }
$$

let the positive integer $k$ satisfy $x_{k} \leqslant 1<x_{k+1}$.
Since $f(x)$ is decreasing on the interval $[0,1]$ and increasing on the interval $(1,4]$, we have
$$
\begin{array}{l}
\sum_{i=1}^{n}\left|f\left(x_{i}\right)-f\left(x_{i-1}\right)\right| \\
=\sum_{i=1}^{k}\left|f\left(x_{i}\right)-f\left(x_{i-1}\right)\right|+\left|f\left(x_{k+1}\right)-f\left(x_{k}\right)\right|+ \\
\sum_{i=k+2}^{n}\left|f\left(x_{i}\right)-f\left(x_{i-1}\right)\right| \\
=f(0)-f\left(x_{k}\right)+\left|f\left(x_{k+1}\right)-f\left(x_{k}\right)\right|+ \\
f(4)-f\left(x_{k+1}\right) \\
=10+\left|f\left(x_{k+1}\right)-f\left(x_{k}\right)\right|-f\left(x_{k+1}\right)-f\left(x_{k}\right) \text {. } \\
\end{array}
$$

If $f\left(x_{k+1}\right) \geqslant f\left(x_{k}\right)$, then
$$
\sum_{i=1}^{n}\left|f\left(x_{i}\right)-f\left(x_{i-1}\right)\right|=10-2 f\left(x_{k}\right) \leqslant 10 \text {, }
$$

with equality holding when $x_{k}=1$.
If $f\left(x_{k+1}\right)<f\left(x_{k}\right)$, then
$$
\sum_{i=1}^{n}\left|f\left(x_{i}\right)-f\left(x_{i-1}\right)\right|=10-2 f\left(x_{k+1}\right)<10 \text {. }
$$

Thus, for any partition of the interval $[0,4]$, we have
$$
\sum_{i=1}^{n}\left|f\left(x_{i}\right)-f\left(x_{i-1}\right)\right| \leqslant 10 \text {, }
$$

with equality holding if there exists an $x_{k}=1$.
Hence, the maximum value of $\sum_{i=1}^{n}\left|f\left(x_{i}\right)-f\left(x_{i-1}\right)\right|$ is 10.
Therefore, $M_{\min }=10$.