How to merge tensor with weights?

I have a tensor list [A1 A2 A3 A4] and a weights [w1, w2, w3, w4].I want get a list [w1A1 w2 A2 w3* A3 w4* A4]. I write a program as below:

        for i in range(C):
            for j in range(BatchSize):
               a[i][j] = a[i][j].clone() * w[j][i].expand_as(bottleneck[i][j])

but the time spending on calculating is too much. how can i improve it?

you should use