code: def to_onehot(feat: Variable, size: int) -> Variable:
      """
      Transform features into one-hot vectors
      """
      dim = [d for d in feat.size()]
      vec_ = torch.unsqueeze(feat, len(dim))
      dim.append(size)
      one_hot = zerovar(dim)
      one_hot.data.scatter_(len(dim) - 1, vec_.data, 1)
      return one_hot
  
imports: from typing import Iterable, Optional
  import torch
  from .cuda import Variable, zerovar
label_desc: Use image node_id 1 for calling a global function with example usage: to_onehot(feat, size) and returns: one_hot