Apply function for each row

I want to apply a function for each row of tensor independly. This function have ‘while’ inside it self, so it would be non-linear transformation.

I was thinking about using apply, but look like that it is not the best method, because it need CPU data and it is not high performance (?) based on documentation.

I would like to work it like that:

data_trans = data.apply(lambda x :  my_function(t))