def METHOD_NAME(module):
    if (
        module != self
        and hasattr(module, "set_beam_size")
        and module not in seen
    ):
        seen.add(module)
        module.set_beam_size(beam_size)