Could you explain what the shapes of preds and target represent?
Currently it seems preds uses a batch size of 10, while you have a single target, which will then raise this error after flattening these tensors.
PS: you can post code snippets by wrapping them into three backticks ```, which makes debugging easier.