code: def to_onehot(x):
      out = moveaxis(F.one_hot(torch.as_tensor(x).long())[0], -1, 0)
      out, *_ = convert_to_dst_type(out, x)
      return out
  
file_path: MONAI/tests/test_keep_largest_connected_component.py
imports: from __future__ import annotations
  import unittest
  from copy import deepcopy
  import torch
  import torch.nn.functional
  from parameterized import parameterized
  from monai.transforms import KeepLargestConnectedComponent
  from monai.transforms.utils_pytorch_numpy_unification import moveaxis
  from monai.utils.type_conversion import convert_to_dst_type
  from tests.utils import TEST_NDARRAYS, assert_allclose
label_desc: Use image node_id 1 for calling a global function with example usage: to_onehot(x) and returns: out