  In the framework of multidimensional $f(R)$ gravity, we study the metrics of
compact extra dimensions assuming that our 4D space has the de Sitter metric.
Manifolds described by such metrics could be formed at the inflationary and
even higher energy scales. It is shown that in the presence of a scalar field,
varying in the extra factor space $\mathbb{M}_2$, it is possible to obtain a
variety of inhomogeneous metrics in $\mathbb{M}_2$. Each of these metrics leads
to a certain value of the 4D cosmological constant $\Lambda_4$, and in
particular, it is possible to obtain $\Lambda_4 =0$, as is confirmed by
numerically obtained solutions. A nontrivial scalar field distribution in the
extra dimensions is an important feature of this family of models.
