In any action filed by the local child support agency pursuant to Section 17402 or 17404, the local child support agency shall provide the mother and the alleged father the opportunity to voluntarily acknowledge paternity by signing a paternity declaration as described in Section 7574 prior to a hearing or trial where the paternity of a minor child is at issue. The opportunity to voluntarily acknowledge paternity may be provided either before or after an action pursuant to Section 17402 or 17404 is filed and served upon the alleged father. For the purpose of meeting the requirements of this section, the local child support agency may afford the defendant an opportunity to enter into a stipulation for judgment of paternity after an action for paternity has been filed in lieu of the voluntary declaration of paternity.