The .map() method is central to tf.data pipelines. Besides parsing samples, it is also applied to edit them further. For example, in computer vision, it is common for some applications to crop/resize input images to the same dimensions (for instance, applying tf.image.resize()) or to one-hot target labels (tf.one_hot()).
As we will detail later in this chapter, it is also recommended to wrap the optional augmentations for training data into a function passed to .map().