A method performed by one or more data processing apparatus, the method comprising: receiving a request to generate a plurality of possible segmentations (104; 306; 406) of an image (102; 302; 402); sampling a plurality of latent variables from a latent space, wherein each latent variable is sampled from the latent space in accordance with a respective probability distribution over the latent space that is determined based at least in part on the image (102; 302; 402), wherein: the latent space comprises a hierarchy of latent sub-spaces; and sampling a latent variable from the latent space comprises sampling a respective latent sub-variable from each latent sub-space of the latent space, wherein sampling a latent sub-variable from a given latent sub-space comprises: generating a probability distribution over the given latent sub-space based on: (i) the image (102; 302; 402), and (ii) latent sub-variables sampled from any latent sub-spaces that precede the given latent sub-space in the hierarchy of latent sub-spaces; and sampling the latent sub-variable from the given latent sub-space in accordance with the probability distribution over the given latent sub-space; generating a plurality of possible segmentations (104; 306; 406) of the image (102; 302; 402), comprising, for each latent variable, processing the image (102; 302; 402) and the latent variable using a segmentation neural network (112; 304) having a plurality of segmentation neural network parameters to generate the possible segmentation of the image (102; 302; 402); and providing the plurality of possible segmentations (104; 306; 406) of the image (102; 302; 402) in response to the request. receiving a request to generate a plurality of possible segmentations (104; 306; 406) of an image (102; 302; 402); sampling a plurality of latent variables from a latent space, wherein each latent variable is sampled from the latent space in accordance with a respective probability distribution over the latent space that is determined based at least in part on the image (102; 302; 402), wherein: the latent space comprises a hierarchy of latent sub-spaces; and sampling a latent variable from the latent space comprises sampling a respective latent sub-variable from each latent sub-space of the latent space, wherein sampling a latent sub-variable from a given latent sub-space comprises: generating a probability distribution over the given latent sub-space based on: (i) the image (102; 302; 402), and (ii) latent sub-variables sampled from any latent sub-spaces that precede the given latent sub-space in the hierarchy of latent sub-spaces; and sampling the latent sub-variable from the given latent sub-space in accordance with the probability distribution over the given latent sub-space; the latent space comprises a hierarchy of latent sub-spaces; and sampling a latent variable from the latent space comprises sampling a respective latent sub-variable from each latent sub-space of the latent space, wherein sampling a latent sub-variable from a given latent sub-space comprises: generating a probability distribution over the given latent sub-space based on: (i) the image (102; 302; 402), and (ii) latent sub-variables sampled from any latent sub-spaces that precede the given latent sub-space in the hierarchy of latent sub-spaces; and sampling the latent sub-variable from the given latent sub-space in accordance with the probability distribution over the given latent sub-space; generating a probability distribution over the given latent sub-space based on: (i) the image (102; 302; 402), and (ii) latent sub-variables sampled from any latent sub-spaces that precede the given latent sub-space in the hierarchy of latent sub-spaces; and sampling the latent sub-variable from the given latent sub-space in accordance with the probability distribution over the given latent sub-space; generating a plurality of possible segmentations (104; 306; 406) of the image (102; 302; 402), comprising, for each latent variable, processing the image (102; 302; 402) and the latent variable using a segmentation neural network (112; 304) having a plurality of segmentation neural network parameters to generate the possible segmentation of the image (102; 302; 402); and providing the plurality of possible segmentations (104; 306; 406) of the image (102; 302; 402) in response to the request.