Adapt link visibility script to collections

I was wondering: is there a way to make this script also toggle the eye/render icons of the collections? I know that it is an aesthetic change because the result is the same.

import bpy

def hide(scene): for o in scene.objects: o.hide_render = o.hide_get()

return None