This has got a lot better more recently as we now have hybrid trains that can run on electricity whenever there are overhead lines, and diesel where there aren't. There is talk of replacing diesel engines with batteries so that they can run on electric (and use regenerative braking) even where there are no overhead lines, charging the batteries from the overhead line when available. https://anonw.com/2023/06/27/what-will-be-the-range-of-a-hit...
There are usually multiple diesel generators on each train, so it's likely that the batteries will only replace some of them - there would still be some diesel power available for emergencies.
Seems they're moving towards partially electrifying, and using battery or hydrogen for the remaining part. They've already started to acquire bimodal trains[3] for the transition.
[1]: https://www.tu.no/artikler/hydrogen-som-drivstoff-for-godsto...
[2]: https://no.wikipedia.org/wiki/Nordlandsbanen
[3]: https://www.norsketog.no/nyheter/2020/testkjorer-tronderbane...
But I think that there was/is plan to electrify them as well.
But instead the rail companies have actually been tearing down existing electrification. There were 3100 miles of electrified rails in the 1930s, but now it is down to a tiny fraction of that.