code: def randomized_onehot_round(x: np.ndarray) -> np.ndarray:
      """Randomized rounding of x to a one-hot vector.
      x should be 0 <= x <= 1."""
      if len(x) == 1:
          return np.array([randomized_round(x[0])])
      if sum(x) == 0:
          x = np.ones_like(x)
      w = x / sum(x)
      hot = np.random.choice(len(w), size=1, p=w)[0]
      z = np.zeros_like(x)
      z[hot] = 1
      return z
  
file_path: Ax/ax/modelbridge/transforms/rounding.py
imports: import math
  import random
  from copy import copy
  from typing import Set
  import numpy
  from ax.core.parameter_constraint import OrderConstraint
  from ax.core.search_space import SearchSpace
  from ax.core.types import TParameterization
label_desc: Use image node_id 2 for calling a global function with example usage: randomized_onehot_round(x) and returns: z, np