From the docs:

weight (Tensor, optional) – a manual rescaling weight given to the loss of each batch element. If given, has to be a Tensor of size nbatch.

so you would have to provide a weight value for each sample in the batch.