<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def coordinates_to_index(self, x, y, x_shift=0, y_shift=0):
 """ Return a linear index from a set of 2D coordinates. Optionnal vertical and horizontal shifts might be applied. """

        target_x = x + x_shift
        target_y = y + y_shift
        self.validate_coordinates(target_x, target_y)
        index = (target_y * self.length) + target_x
        return index