Recently, the self-similar collapse of the polytropic cylinders in the ideal MHD regime has
been targeted by many theoretical works. However, it has not yet been fully understood in
the non-ideal MHD regime. In this regard, we consider the impact of ambipolar diffusion, i.e.
non-ideal MHD regime, on the self-similar collapse of a magnetized filament in two different
scenarios as isothermal and polytropic configurations. Herein, we apply a self-similar dynamic
formalism for a magnetized, infinitely long, axisymmetric cylinder under self-gravity with a
toroidal magnetic field. The self-similar solution in the non-ideal MHD regime highlights the
important role of the ambipolar diffusion coefficient discussed in detail in the following. The
flux-to-mass ratio in the ideal MHD regime appears as a constant. Our results show that the
presence of ambipolar diffusion leads to a variable flux-to-mass ratio in both studied scenarios.
The comparison between the isothermal and polytropic collapses in a magnetized filament can
be discussed using the results of this study. In addition, according to the obtained results, the
impact of ambipolar diffusion in the gravitational collapse as well as in the star formation is
important.