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

def imfill(immsk):
    '''fill the empty patches of image mask 'immsk' '''

    for iz in range(immsk.shape[0]):
        for iy in range(immsk.shape[1]):
            ix0 = np.argmax(immsk[iz,iy,:]>0)
            ix1 = immsk.shape[2] - np.argmax(immsk[iz,iy,::-1]>0)
            if (ix1-ix0) > immsk.shape[2]-10: continue
            immsk[iz,iy,ix0:ix1] = 1
    return immsk