cv2.imwrite will return a bool value to indicate, if the write process was successful or not, which you are reassigning to sample before passing to self.transform.
Remove the assignment and rerun the code.