I think I have something that works:
import torch
import torch.autograd as autograd
import torch.nn as nn
input = autograd.Variable(torch.randn(3,9).double(), requires_grad=True)
target = autograd.Variable(torch.randn(3,2).random_(0,8).long(), requires_grad=False)

input_species = input[:,:8]
input_length  = input[:,8]
target_species = target[:,0]
target_length  = target[:,1].double()
loss = nn.MSELoss()(input_length, target_length) * 1e-4 + nn.NLLLoss()(input_species, target_species)
loss.backward()

Is this what you’re looking for?