Please help me with this slow for loop tensor calculation

is there any way to make this faster by using library function?
Please help me with this…

It uses three tensor

input= tensor with size(minibatch,3,Height+51,Width+51)
gradoutput= tensor with size(minibatch,3, Height, Width)
kernel =tensor with size(minibatch,51, Height, Width)
grad=new tensor with size(minibatch,3, Height, Width)

for n in range(minibatch):		
		for i in range(Height):
			for j in range(Width):
				for k in range(3):
					for c in range(3):
						for l in range(51):