import torch


def word_to_one_hot(word, word2idx):
  """Return the one hot encoding of the word given to this function. 
  
    Args:
      word (str): The word for which one hot representation is required.
      word2idx (Dict): The dictionary mapping from word to indices.

    Returns:
      x (torch.Tensor): The one hot representation for the word.
  """

  # Create a vector or zeros equal to the length of the vocab
  x = torch.zeros(len(word2idx)).float() 
  
  # Setting the value corresponding to the index of word 1
  x[word2idx[word]] = 1.0 
  
  return x