When any person is involuntarily placed with the Department of Developmental Services pursuant to the provisions of § 17a-274, all fees and expenses incurred upon such proceedings shall be paid by the state; and, if such person is not involuntarily placed with the department, such fees and expenses shall be paid by the petitioner.