Whenever it appears upon any accounting or in any appropriate action or proceeding that a personal representative, executor, administrator, trustee, or other person acting in a fiduciary capacity has paid or may be required to pay any transfer tax levied or assessed under sections 77-2101 to 77-2116 or under the provisions of any federal estate or generation-skipping transfer tax law heretofore or hereafter enacted upon or with respect to any property required to be included in the gross estate of a decedent or total amount of generation-skipping transfer under the provisions of any such law, the amount of the tax so paid or payable, except as otherwise directed in the decedent's will or except in a case when by written instrument executed inter vivos direction is given for apportionment within the fund of the taxes assessed upon the specific fund dealt with in such inter vivos instrument, shall be equitably apportioned and prorated among the persons interested in the estate or transfer. Such apportionment and proration shall be made in the proportion as near as may be that the value of the property, interest, or benefit of each such person bears to the total value of the property, interests, or benefits received by all such persons interested in the estate or transfer, except that in making such proration, allowances shall be made for any exemptions granted by the law imposing the tax and for any deductions, including any marital deduction, allowed by such law for the purpose of arriving at the value of the net estate or transfer. In cases when a trust is created or other provision made by which any person is given an interest in income or an estate for years or for life or any other temporary interest in any property or fund, the tax on both such temporary interest and on the remainder thereafter shall be charged against and be paid out of the corpus of such property or fund without apportionment between remainders and temporary estates.