When running the Notebook some problems are generated when executing the last cells, but they are due to some parameters received by the remap function of cv2 inside the undistortRectify function.
I have a slightly different version of the code that generates the same output as the original and it works in practice.
def undistortRectify(imageR, imageL, stereoMapL_x=stereoMapL[1], stereoMapL_y=stereoMapL[0], stereoMapR_x=stereoMapR[0], stereoMapR_y=stereoMapR[1]):
# Undistort and rectify images
undistortedL= cv.remap(imageL, stereoMapL_x, stereoMapL_y, cv.INTER_LANCZOS4, cv.BORDER_CONSTANT, 0)
undistortedR= cv.remap(imageR, stereoMapR_x, stereoMapR_y, cv.INTER_LANCZOS4, cv.BORDER_CONSTANT, 0)
return undistortedR, undistortedL