For starters, I am getting this error even while trying to run lr_find

```
lovasz_hinge
loss = mean(lovasz_hinge_flat(*flatten_binary_scores(log.unsqueeze(0), lab.unsqueeze(0), ignore))
NameError: name 'mean' is not defined
```

This is the code I am using fordef lovasz_loss(logits, labels):

def lovasz_loss(logits, labels):

labels, logits = labels.squeeze(1),logits.squeeze(1)

loss = lovasz_hinge(logits, labels, per_image = True, ignore = None)

return loss

```
def lovasz_hinge(logits, labels, per_image=True, ignore=None):
if per_image:
loss = mean(lovasz_hinge_flat(*flatten_binary_scores(log.unsqueeze(0), lab.unsqueeze(0), ignore))
for log, lab in zip(logits, labels))
else:
loss = lovasz_hinge_flat(*flatten_binary_scores(logits, labels, ignore))
return loss
def lovasz_hinge_flat(logits, labels):
if len(labels) == 0:
return logits.sum() * 0.
signs = 2. * labels.float() - 1.
errors = (1. - logits * Variable(signs))
errors_sorted, perm = torch.sort(errors, dim=0, descending=True)
perm = perm.data
gt_sorted = labels[perm]
grad = lovasz_grad(gt_sorted)
loss = torch.dot(F.relu(errors_sorted), Variable(grad))
return loss
def lovasz_grad(gt_sorted):
p = len(gt_sorted)
gts = gt_sorted.sum()
intersection = gts - gt_sorted.float().cumsum(0)
union = gts + (1 - gt_sorted).float().cumsum(0)
jaccard = 1. - intersection / union
if p > 1: # cover 1-pixel case
jaccard[1:p] = jaccard[1:p] - jaccard[0:-1]
return jaccard
def flatten_binary_scores(scores, labels, ignore=None):
scores = scores.view(-1)
labels = labels.view(-1)
if ignore is None:
return scores, labels
valid = (labels != ignore)
vscores = scores[valid]
vlabels = labels[valid]
return vscores, vlabels
```

And this is where I am getting the error

```
loss_func=lovasz_loss
optimizer=optim.SGD
learn = ConvLearner(md, models)
learn.opt_fn=optimizer
learn.crit=loss_func
learn.metrics=[accuracy_thresh(0.5),dice]
learn.freeze_to(1)
learn.lr_find()
learn.sched.plot()
```

And when I include the mean function by importing statistics, there is a different error.