def rand_crop(sz, *imagez):
def _rand_crop(*imgz):<EOL><INDENT>imsz = imgz[<NUM_LIT:0>].shape[:<NUM_LIT:2>]<EOL>assert imsz[<NUM_LIT:0>] >= sz[<NUM_LIT:0>] and imsz[<NUM_LIT:1>] >= sz[<NUM_LIT:1>]<EOL>si = np.random.randint(imsz[<NUM_LIT:0>] - sz[<NUM_LIT:0>]) if imsz[<NUM_LIT:0>] > sz[<NUM_LIT:0>] else <NUM_LIT:0><EOL>sj = np.random.randint(imsz[<NUM_LIT:1>] - sz[<NUM_LIT:1>]) if imsz[<NUM_LIT:1>] > sz[<NUM_LIT:1>] else <NUM_LIT:0><EOL>slicei = slice(si, si+sz[<NUM_LIT:0>])<EOL>slicej = slice(sj, sj+sz[<NUM_LIT:1>])<EOL>outs = tuple(img[slicei, slicej] for img in imgz)<EOL>return tuple_or_not(*outs)<EOL><DEDENT>return _rand_crop(*imagez) if imagez else _rand_crop<EOL>
random crop
# assume imagez has same size (H, W)
# assume sz is less or equal than size of image
:param sz: cropped image sz
:param imagez: imagez
:return: rand cropped image pairs or function bound to sz