code: def transform_to_2hot(
      scalar: Array, min_value: float, max_value: float, num_bins: int
  ) -> Array:
      """Transforms a scalar tensor to a 2 hot representation."""
      scalar = jnp.clip(scalar, min_value, max_value)
      scalar_bin = (
          (scalar - min_value)
          / (max_value - min_value)
          * (num_bins - 1)
      )
      lower, upper = jnp.floor(scalar_bin), jnp.ceil(scalar_bin)
      lower_value = (lower / (num_bins - 1.0)) * (
          max_value - min_value
      ) + min_value
      upper_value = (upper / (num_bins - 1.0)) * (
          max_value - min_value
      ) + min_value
      p_lower = (upper_value - scalar) / (
          upper_value - lower_value + 1e-5
      )
      p_upper = 1 - p_lower
      lower_one_hot = base.one_hot(
          lower, num_bins, dtype=scalar.dtype
      ) * jnp.expand_dims(p_lower, -1)
      upper_one_hot = base.one_hot(
          upper, num_bins, dtype=scalar.dtype
      ) * jnp.expand_dims(p_upper, -1)
      return lower_one_hot + upper_one_hot
  
file_path: rlax/rlax/_src/transforms.py
imports: import chex
  import jax
  import jax.numpy
  from rlax._src import base
label_desc: Use image node_id 11 for calling a global function with example usage: transform_to_2hot(scalar, min_value, max_value, num_bins) and returns: unknown