tensor you show has shape (1,3,3,5)
You can imagine it as a 1x parallelogram with dimensions 3x3x5
Flattening is pretty much ‘scanning’ it line by line, so you can flatten (3,3,5) to (3,15)
torch.flatten(x, -2, -1) will flatten your 1x3x3x5 tensor to 1x3x15 you were looking for (other option is to  use view)