Transform is the main building block of data pipelines in fastai. And elsewhere if you want.
copied from cf-post-staging / fasttransformTransform is a class that lets you create reusable data transformations. You initialize a Transform by passing in or decorating a raw function. The Transform then provides an enhanced version of that function via Transform.encodes, which can be used in your data pipeline.
It provides various conveniences: - Reversibility. You can collect the raw function and its inverse into one transform object. - Customized initialization. You can customize the exact behavior of a transform function on initialization. - Type-based multiple dispatch. Transforms can specialize their behavior based on the runtime types of their arguments. - Type conversion/preservation. Transforms help you maintain desired return types.