The foregoing provisions of this chapter shall not apply where and to the extent that a testator provides in the testator's will for another method of apportionment or allocation of the taxes referred to in § 2901 of this title or where and to the extent that the written terms of an inter vivos transfer provide for another method of apportionment or allocation of such taxes which may be imposed with respect to the specific fund so transferred. Such provision in a will or in the terms of an inter vivos transfer may be in the form of a direction or of a grant of discretion to an executor or trustee to apportion or allocate such taxes or to pay such taxes out of the residuary estate under a will or from any other portion or portions of the estate passing under the will or out of the property transferred inter vivos.