How to recover from Ubuntu fix packages and versions after dist-upgrade went wrong?

When dist-upgrading Ubuntu 20.4, something went wrong and the GUI is not starting now.

I tried to do different things from the terminal:

  • sudo apt --fix-broken install gives the error Error, pkgProblemResolver::Resolve generated breaks, this might be caused by held packages

  • same for sudo apt-get install -f

  • sudo dpkg --configure -a returns Processing was halt because there were too many errors: The errors are like error processing package

    • dependency problems prevent configuration of <package-_name>. <package_name> depends on <package_2> (>= 0.2.0) however package2 is not configured yet
    • dependency problems prevent configuration of <package_name>. <package_name> depends on <package_2> (>= 0.2.0) however version of package2 on system is x.x.x

Among the errors there are many Python ones (3.8 vs 3.10), perc etc.

I was trying to remove the dependencies manually with dpkg --purge almost one by one by removing first the packages having that dependency and then the package itself, but got to some dead-ends.
One for example is that to remove one package that was causing error it asked to remove update-manager but it seems that update-manager, ubuntu-release-upgrader-tk, update-manager-gnome and update notifier have a sort of circular dependency.
Another problem is that it would require to remove whole python which I don’t think should be done.

Basically, I cannot autoremove, update