If I call gO = torch.Tensor([1,1,1]) the tensor you give to the backward() function, the a.grad contains:
<gO[0] * db1/da1 + gO[1] * db2/da1 + gO[2] * db3/da1, gO[0] * db1/da2 + gO[1] * db2/da2 + gO[2] * db3/da2, gO[0] * db1/da3 + gO[1] * db2/da3 + gO[2] * db3/da3>.
In you particular case, b is the element-wise product of a and 2 so dbi/daj is 0 if i != j and 2 if i==j. So it will boil down in your case to <12 + 10 + 10, 10 + 12 + 10, 10 + 10 + 1*2> = <2, 2, 2>.