Solved by KFrank in post #2 
              
              
                Hi Zimo! 

There are lots of possibilities.  (You could choose between them by 
imposing further conditions on the behavior of your function.) 
Here is an illustration of one possible choice: 
>>> import torch
>>> torch.__version__
'1.7.1'
>>> _ = torch.manual_seed (2021)
>>> def gradual (values, p)…