<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_pil_mode(value, alpha=False):
 """Get PIL mode from ColorMode."""

    name = {
        'GRAYSCALE': 'L',
        'BITMAP': '1',
        'DUOTONE': 'L',
        'INDEXED': 'P',
    }.get(value, value)
    if alpha and name in ('L', 'RGB'):
        name += 'A'
    return name