Every officer of the state, or of any county, city, or judicial district who accepts, keeps, retains or diverts for his own use or the use of any other person any part of the salary or fees allowed by law to his deputy, or other subordinate officer, is guilty of a felony punishable by imprisonment in the state prison for 16 months, or two or three years.