The trains in the IEP contracts were specified by the DfT.
The design, development, manufacture and testing of the trains and the construction of the assembly plant in Newton Aycliffe[1] was paid for by Hitachi using its own and, mostly, borrowed money. The construction/modification of the depots was paid for by Agility Trains which also carries out all maintenance and cleaning.
The TOCs pay Agility Trains for each completed diagram - with adjustments for short formations/not properly presented trains/etc. The TOC is obliged to get a specific train back to its pre-determined maintenance depot at the end of the diagram - if it doesn't further adjustments are made.
The payments are set down in the various DfT/Agility Trains contracts. The TOCs make the payments to Agility Trains but these payments are guaranteed by the DfT for the duration of the contract - in this case for 27 1/2 years.
[1] There was government/local government 'sweetener' made in connection with the construction of the plant.
So, in short the taxpayer then.