The Islamic State group has claimed responsibility for the deadly mosque attack in Afghanistan that killed dozens of people in a Shia mosque.