An ACK acknowledges the arrival of all data up to a specific sequence number at the peer, not the arrival of a specific packet. Because the data will not change with retransmission it does not matter if the ACK was generated for the first or the second try. The sender might even merge multiple lost data together into new packets for retransmission.
Say 2 end points are communicating over TCP. 'A' sends some data to 'B' and expects 'B' to ACK it. However it takes more time than usual and the retransmission timer at 'A' expires, hence the same data is sent once again. Then the ACK from 'B'(from the first time the data was sent) finally arrives. So now how does TCP treat this ACK? Does it treat this ACK as an acknowledgement of the first time that data was sent? or as an acknowledgment of the data sent the second time?