def model_str(module):
    """ Output model structure and parameters number as strings.
    """
    row_format = '  {name:<40} {shape:>20} = {total_size:>12,d}'
    lines = ['  ' + '-' * 76,]

    params = list(module.named_parameters())
    for name, param in params:
        lines.append(row_format.format(name=name,
            shape=' * '.join(str(p) for p in param.size()), total_size=param.numel()))

    lines.append('  ' + '-' * 76)
    lines.append(row_format.format(name='all parameters', shape='sum of above',
        total_size=sum(int(param.numel()) for name, param in params)))
    lines.append('  ' + '=' * 76)
    lines.append('')

    return '\n'.join(lines)