These days there is a torch.nn.functional.one_hot 13 that does what you need except that the label dimension is last, but one_hot + permute will get you what you need.
You can (almost) always use torch.from_numpy(array) and tensor.numpy() to get from and to numpy efficiently.
Best regards
Thomas