<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def plot_chmap(cube, kidid, ax=None, **kwargs):
 """Plot an intensity map. Args: cube (xarray.DataArray):
 Cube which the spectrum information is included. kidid (int):
 Kidid. ax (matplotlib.axes):
 Axis the figure is plotted on. kwargs (optional):
 Plot options passed to ax.imshow(). """

    if ax is None:
        ax = plt.gca()

    index = np.where(cube.kidid == kidid)[0]
    if len(index) == 0:
        raise KeyError('Such a kidid does not exist.')
    index = int(index)

    im = ax.pcolormesh(cube.x, cube.y, cube[:, :, index].T, **kwargs)
    ax.set_xlabel('x')
    ax.set_ylabel('y')
    ax.set_title('intensity map ch #{}'.format(kidid))
    return im