Yang-Mills gauge anomalies in the presence of gravity with torsion