Toward Task Capable Active Matter: Learning to Avoid Clogging in Confined Collectives via Collisions