<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def _get_dimension_scales(self, dimension, preserve_domain=False):
 """ Return the list of scales corresponding to a given dimension. The preserve_domain optional argument specifies whether one should filter out the scales for which preserve_domain is set to True. """

        if preserve_domain:
            return [
                self.scales[k] for k in self.scales if (
                    k in self.scales_metadata and
                    self.scales_metadata[k].get('dimension') == dimension and
                    not self.preserve_domain.get(k)
                )
            ]
        else:
            return [
                self.scales[k] for k in self.scales if (
                    k in self.scales_metadata and
                    self.scales_metadata[k].get('dimension') == dimension
                )
            ]