def sample(x, diff, low=0, high=1, only_less=False, only_more=False):
        """
        sample a float from max(0, x-diff) and min(1, x+diff) if diff is not
        None. Else sample a number from low to high
        :param only_less: valid when diff is not None. only samples a small
            value
        :param only_more:
        """
        if diff is None:
            out = np.random.uniform(low, high)
        else:
            lb = max(0, x) if only_more else max(0, x - diff)
            ub = min(1, x) if only_less else min(1, x + diff)
            out = np.random.uniform(lb, ub)
        return out

        sample a float from max(0, x-diff) and min(1, x+diff) if diff is not
        None. Else sample a number from low to high
        :param only_less: valid when diff is not None. only samples a small
            value
        :param only_more:
        
infinigen/core/util/random.py