Thanks!
I now did
if x.dim() <= 1:
    x = x.expand(1, *(x.size() or [1]))

which does the job, but unfortunately must be part of my forward method.
What kind of toll does this check have on performance?