# *** RuntimeError: a leaf Variable that requires grad has been used in an in-place operation

I defined a type of loss and encounter *** RuntimeError: a leaf Variable that requires grad has been used in an in-place operation. The loss is defined as follows

def SMLoss(feature):
co=feature.mm(feature.t())
l=co.diag().resize(batch_size,1).sqrt()
S=co.div(l.mm(l.t()))+1
W=S.resize(le,1)