I think the cleanest approach would be to either define a custom transformation and add the logic to the __call__ method in your object or to use e.g. transforms.Lambda and pick the transformation based on the random number.