<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def _apply_discrete_colormap(arr, cmap):
 """ Apply discrete colormap. Attributes arr : numpy.ndarray 1D image array to convert. color_map: dict Discrete ColorMap dictionary e.g: { 1: [255, 255, 255], 2: [255, 0, 0] } Returns ------- arr: numpy.ndarray """

    res = np.zeros((arr.shape[1], arr.shape[2], 3), dtype=np.uint8)
    for k, v in cmap.items():
        res[arr[0] == k] = v
    return np.transpose(res, [2, 0, 1])