Transform function for both the input and target variable

Hello!

I was wondering how can you implement transforms, that require both the input and target variable.

An example use for the case of binary segmentation task:

  1. If the target image contains positive pixels(pp)
  2. Do random crop around some random pp for both the input and target images
  3. The crop must include at least N pp in the target image
  4. If the crop does not fulfill the predicate than create another crop

The only way I imagine it right now is to use the preprocessor class. What are your thoughts?