<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:

def list_licenses(service_instance=None):
    '''
    Lists all licenses on a vCenter.

    service_instance
        Service instance (vim.ServiceInstance) of the vCenter/ESXi host.
        Default is None.

    .. code-block:: bash

        salt '*' vsphere.list_licenses
    '''
    log.trace('Retrieving all licenses')
    licenses = salt.utils.vmware.get_licenses(service_instance)
    ret_dict = [{'key': l.licenseKey,
                 'name': l.name,
                 'description': l.labels[0].value if l.labels else None,
                 # VMware handles unlimited capacity as 0
                 'capacity': l.total if l.total > 0 else sys.maxsize,
                 'used': l.used if l.used else 0}
                 for l in licenses]
    return ret_dict