172(d)(4). (B) Source of gain or loss from derivatives In the case of a taxable event with respect to a derivative, any item of income, deduction, gain, or loss taken into account under subsection (a) shall be treated as derived from sources within the country of residence of the taxpayer. (2) Determination of amount (A) In general The amount of gain or loss taken into account under subsection (a) with respect to a taxable event shall be— (i) in the case of a taxable event involving the termination or transfer of a derivative or the sale or exchange of an underlying investment, the amount of gain or loss determined under this title with respect to the taxable event, or (ii) in the case of any other taxable event, the amount of gain or loss which would be determined under this title if, immediately before the taxable event— (I) in the case of a derivative, the derivative were terminated or transferred at its fair market value, or (II) in the case of an underlying investment, the investment were sold or exchanged at its fair market value. (B) Reliance on valuation For purposes of subparagraph (A), the taxpayer may rely on a valuation which is— (i) provided to the taxpayer by a broker under section 6045(b), or (ii) determined under an applicable financial statement. (3) Special rules for taxable events with respect to investment hedging units (A) In general In the case of a taxable event described in subsection (c)(2) with respect to a derivative or underlying investment (other than a termination or transfer of the derivative or the sale or exchange of the underlying investment)— (i) notwithstanding subsection (a), built-in loss (if any) with respect to the derivative or underlying investment shall not be recognized and shall not be taken into account by reason of such taxable event, and (ii) notwithstanding paragraph (1), built-in gain (if any) with respect to the underlying investment shall be treated as long-term or short-term capital gain if the built-in gain would have been so treated if the investment were