code: def make_padded_tree(
      limits, height, padding, rng=random, **node_params
  ):
      if height == 0:
          return HSTLeaf(**node_params)
  
      # Randomly pick a feature
      # We weight each feature by the gap between each feature's limits
      on = rng.choices(
          population=list(limits.keys()),
          weights=[limits[i][1] - limits[i][0] for i in limits],
      )[0]
  
      # Pick a split point; use padding to avoid too narrow a split
      a = limits[on][0]
      b = limits[on][1]
      at = rng.uniform(a + padding * (b - a), b - padding * (b - a))
  
      # Build the left node
      tmp = limits[on]
      limits[on] = (tmp[0], at)
      left = make_padded_tree(
          limits=limits,
          height=height - 1,
          padding=padding,
          rng=rng,
          **node_params,
      )
      limits[on] = tmp
  
      # Build the right node
      tmp = limits[on]
      limits[on] = (at, tmp[1])
      right = make_padded_tree(
          limits=limits,
          height=height - 1,
          padding=padding,
          rng=rng,
          **node_params,
      )
      limits[on] = tmp
  
      return HSTBranch(
          left=left,
          right=right,
          feature=on,
          threshold=at,
          **node_params,
      )
  
imports: from __future__ import annotations
  import collections
  import functools
  import random
  from river import anomaly, base, tree
label_desc: Use image node_id 1 for calling a global function with example usage: make_padded_tree(limits, height, padding, rng) and returns: HSTBranch, HSTLeaf