import torch


def bounded_scale_function(bounds):
  """
    Sets up a scaling function that maps `(0,1)` to `(bounds[0], bounds[1])`
    and clips the values to remain in that range

    Args:
      bounds:   tuple giving the parameter bounds
  """
  return lambda x: torch.clamp(x, 0, 1)*(bounds[1]-bounds[0]) + bounds[0]