Anything in this chapter to the contrary notwithstanding, whenever any county or city and county maintains a tuberculosis ward, hospital or sanatorium in another county of this state, the governing board of any school district of the county or city and county maintaining such institution, if authorized to maintain classes for adults, may establish and maintain such classes in such institution for pretuberculous, tuberculous, and convalescent minors and adults, and the attendance of pupils in the classes shall be credited to the district maintaining the classes.