Nothing contained in this chapter shall prevent a carrier or a shipper from entering into any agreement, stipulation, condition, reservation, or exemption as to the responsibility and liability of the carrier or the ship for the loss or damage to or in connection with the custody and care and handling of goods prior to the loading on and subsequent to the discharge from the ship on which the goods are carried by sea.