'Replace the fields in the model and return a new instance
Examples::
# Returns a track with a new name
Track(name=\'foo\').replace(name=\'bar\')
# Return an album with a new number of tracks
Album(num_tracks=2).replace(num_tracks=5)
:param kwargs: kwargs to set as fields on the object
:type kwargs: any
:rtype: instance of the model with replaced fields'

def replace(self, **kwargs):

    other = copy.copy(self)
    for (key, value) in kwargs.items():
        if (not self._is_valid_field(key)):
            raise TypeError((u'replace()    got    an    unexpected    keyword    argument    "%s"' % key))
        other._set_field(key, value)
    return other
