code: def to_one_hot(y, depth=None):
      r"""Takes integer with n dims and converts it to 1-hot representation with n + 1 dims.
  
      The n+1'st dimension will have zeros everywhere but at y'th index, where it will be equal to 1.
      Args:
          y: input integer (IntTensor, LongTensor or Variable) of any shape
          depth (int):  the size of the one hot dimension
      """
      y_flat = y.to(torch.int64).view(-1, 1)
      depth = depth or int(torch.max(y_flat)) + 1
      y_one_hot = torch.zeros(
          y_flat.size()[0], depth, device=y.device
      ).scatter_(1, y_flat, 1)
      y_one_hot = y_one_hot.view(*(tuple(y.shape) + (-1,)))
      return y_one_hot
  
file_path: pytorch_tabular/src/pytorch_tabular/utils/nn_utils.py
imports: import torch
  import torch.nn
  from .logger import get_logger
label_desc: Use image node_id 4 for calling a global function with example usage: to_one_hot(y, depth) and returns: y_one_hot