TypeError: tuple indices must be integers or slices, not tuple

The error suggests that rw is a tuple. Check if your dataloader or dataset is yielding tuples instead of arrays/tensors and if so, re-organize it so that it outputs an array or tensor.