I would consider the usage of resize_ to be dangerous and applicable for advanced use cases, and would thus recommend to use tensor.view(1, -1) or tensor.unsqueeze(0) for this use case.
From the docs of resize_:

This is a low-level method. The storage is reinterpreted as C-contiguous, ignoring the current strides (unless the target size equals the current size, in which case the tensor is left unchanged). For most purposes, you will instead want to use  view()  47, which checks for contiguity, or  reshape()  52, which copies data if needed. To change the size in-place with custom strides, see  set_()  8.