Is Talaq given in a state of impurity after having intercourse with wife considered a valid divorce? Is it necessary for any witness to be present at the time of giving divorce?
Bismihi ta'ala
There are two important points for the first part of this question:
1. The Islamic divorce can only take place while the wife is in tuhr, which means she is outside her monthly menstrual cycle (haydh or nifas).
2. This tuhr time is also a time where there has been no conjugal relation between husband and wife. If wife is in tuhr, but they did have conjugal relation, they must wait until her next menstrual cycle to finish, and after that husband can perform divorce.
If these two conditions are not met, talaq will be invalid.
For second part of question, yes, it is a wajib condition for there to be "just" witnesses, which means a minimum of two highly pious and righteous male witnesses.
And Allah knows best.