Code does not correctly calculate cost despite the code seeming right

Glad to hear that you solved it. They did mention the expected dimensions of the labels and logits in the instructions, although they did not actually use the word “transpose” anywhere. I explained the background on the other thread that I linked above.