Section 5I. (1) If the attorney general initiates an action or assumes control of an action brought by a person pursuant to sections 5B to 5O, inclusive, the attorney general shall be awarded his reasonable attorney's fees and expenses incurred in the litigation, including costs, if he prevails in the action.
(2) If the attorney general does not proceed with an action pursuant to sections 5B to 5O, inclusive, and the defendant is the prevailing party, the court may award the defendant reasonable attorneys' fees and costs against the relator upon a written finding that such action was pursued in bad faith or was wholly insubstantial, frivolous, and advanced for the purpose of causing the defendant undue burden, unnecessary expense or harassment.
(3) No liability shall be incurred by the commonwealth, the affected agency or the attorney general for any expenses, attorney's fees or other costs incurred by any person in bringing or defending an action under said sections 5B to 5O, inclusive.