'Internal implementation of ``__repr__``.
This is separated out for ease of use by subclasses that wish to
override the default ``__repr__`` while keeping the same basic
formatting.'

def _format_repr(self, args=[], kwargs={}, defaults={}):

    parts = [repr(a) for a in args]
    parts.extend((u'{0}={1}'.format(name, param_repr_oneline(getattr(self, name))) for name in self.param_names))
    if (self.name is not None):
        parts.append(u'name={0!r}'.format(self.name))
    for (kwarg, value) in kwargs.items():
        if ((kwarg in defaults) and (defaults[kwarg] != value)):
            continue
        parts.append(u'{0}={1!r}'.format(kwarg, value))
    if (len(self) > 1):
        parts.append(u'n_models={0}'.format(len(self)))
    return u'<{0}({1})>'.format(self.__class__.__name__, u',    '.join(parts))
