code: def test_to_onehot(self):
      feat_vec = Variable(torch.LongTensor([[0, 1, 2], [3, 4, 0]]))
      onehot = to_onehot(feat_vec, 5)
      self.assertEqual(onehot.size()[0], 2)
      self.assertEqual(onehot.size()[1], 3)
      self.assertEqual(onehot.size()[2], 5)
  
      expected = np.zeros((2, 3, 5))
      expected[0][0][0] = 1
      expected[0][1][1] = 1
      expected[0][2][2] = 1
      expected[1][0][3] = 1
      expected[1][1][4] = 1
      expected[1][2][0] = 1
  
      for i, row in enumerate(onehot):
          for j, feat in enumerate(row):
              for k, val in enumerate(feat):
                  self.assertEqual(expected[i][j][k], val.item())
  
file_path: pytext/tests/model_utils_test.py
imports: from __future__ import absolute_import, division, print_function, unicode_literals
  import unittest
  import numpy
  import torch
  from pytext.utils.cuda import Variable
  from pytext.utils.model import to_onehot
label_desc: Use image node_id 1 for calling the ModelUtilsTest obj's underlying member method code with example usage: obj.test_to_onehot() without return types