I Change them to
#con_loss=Variable(torch.FloatTensor([]),requires_grad=True)
class ContentLoss(nn.Module):
   def __init__(self,target,weight):
       super(ContentLoss,self).__init__()
       #detach the original computing graph->weight graph
       self.target=target.detach()*weight
       self.weight=weight
       self.criterion=nn.MSELoss()
   def forward(self,input):
       self.loss=self.criterion(input*self.weight,self.target)#MSE LOSS
       self.output=input
       
       return self.output
   def callback(self):
       return self.loss.backward(retain_graph=True)
       ====
class StyleLoss(nn.Module):
   def __init__(self,target,weight):
       super(StyleLoss,self).__init__()
       self.target=target.detach()*weight
       self.weight=weight
       #self.gram=GramMatrix()
       self.criterion=nn.MSELoss()
   def forward(self,input):
       self.output=input.clone()
       input=input.cuda()
       self_G=Gram(input)
       self_G.mul_(self.weight)
       self.loss=self.criterion(self_G,self.target)
       return self.output
   def callback(self):
       return self.loss.backward(retain_graph=True)
def Gram(input):
   a,b,c,d=input.size()#a=batch_size,b=number of features (c,d)=N=c*d->dimension of visualization
   features=input.view(a*b,c*d)
   G=torch.mm(features,features.t())
   return G.div(a*b*c*d)

and Run 

input_param=nn.Parameter(input_img.data)
optimizer=optim.LBFGS([input_param])
num_steps=300
for i in range(num_steps):
   input_param.data.clamp_(0,1)
   optimizer.zero_grad()
   model(input_param)
   style_score=0
   content_score=0
   for sl in style_losses:
       style_score+=sl.callback()
   for cl in content_losses:
       content_score+=cl.callback()
   if i%50==0:
       print("num{}epochs".format(i))
       print("StyleLoss{:4f},Content_loss{:4f}".format(style_score.data[0],content_score.data[0]))
   def closure():
       return style_score+content_score
output=input_param.data.clamp_(0,1)
plt.figure()
inshow(output,title="output Image")
plt.ioff()
plt.show()

USE Callback method instead
the error is ‘StyleLoss’ object has no attribute ‘loss’
it will as same as contentLoss class