<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def _set_defaults(self):
 """ Set configuration parameters for drawing guide """

        valid_locations = {'top', 'bottom', 'left', 'right'}
        horizontal_locations = {'left', 'right'}
        get_property = self.theme.themeables.property
        margin_location_lookup = {'t': 'b', 'b': 't',
                                  'l': 'r', 'r': 'l'}

        # label position
        self.label_position = self.label_position or 'right'
        if self.label_position not in valid_locations:
            msg = "label position '{}' is invalid"
            raise PlotnineError(msg.format(self.label_position))

        # label margin
        # legend_text_legend or legend_text_colorbar
        name = 'legend_text_{}'.format(
            self.__class__.__name__.split('_')[-1])
        loc = margin_location_lookup[self.label_position[0]]
        try:
            margin = get_property(name, 'margin')
        except KeyError:
            self._label_margin = 3
        else:
            self._label_margin = margin.get_as(loc, 'pt')

        # direction of guide
        if self.direction is None:
            if self.label_position in horizontal_locations:
                self.direction = 'vertical'
            else:
                self.direction = 'horizontal'

        # title position
        if self.title_position is None:
            if self.direction == 'vertical':
                self.title_position = 'top'
            elif self.direction == 'horizontal':
                self.title_position = 'left'
        if self.title_position not in valid_locations:
            msg = "title position '{}' is invalid"
            raise PlotnineError(msg.format(self.title_position))

        # title alignment
        tmp = 'left' if self.direction == 'vertical' else 'center'
        self._title_align = self._default('legend_title_align', tmp)

        # by default, direction of each guide depends on
        # the position all the guides
        try:
            position = get_property('legend_position')
        except KeyError:
            position = 'right'

        if position in {'top', 'bottom'}:
            tmp = 'horizontal'
        else:  # left, right, (default)
            tmp = 'vertical'
        self.direction = self._default('legend_direction', tmp)

        # title margin
        loc = margin_location_lookup[self.title_position[0]]
        try:
            margin = get_property('legend_title', 'margin')
        except KeyError:
            self._title_margin = 8
        else:
            self._title_margin = margin.get_as(loc, 'pt')

        # legend_margin
        try:
            self._legend_margin = get_property('legend_margin')
        except KeyError:
            self._legend_margin = 10

        # legend_entry_spacing
        try:
            self._legend_entry_spacing_x = get_property(
                'legend_entry_spacing_x')
        except KeyError:
            self._legend_entry_spacing_x = 5

        try:
            self._legend_entry_spacing_y = get_property(
                'legend_entry_spacing_y')
        except KeyError:
            self._legend_entry_spacing_y = 2