def _split_scene(images, cameras, top_down, captions):
  """Splits scene into query and target.

  Args:
    images: A tensor containing images.
    cameras: A tensor containing cameras.
    top_down: A tensor containing the scene seen from top.
    captions: A tensor containing captions.

  Returns:
    A tuple query, target. The query is a tuple where the first element is the
    sequence of 9 (images, cameras, captions) which can be given to the model
    as context. The second element in the query is the camera angle of the
    viewpoint to reconstruct. The target contains the image corresponding to the
    queried viewpoint, the text description from that viewpoint and an image of
    the scene viewed from above.
  """
  context_image = images[:-1, :, :, :]
  context_camera = cameras[:-1, :]
  context_caption = captions[:-1]
  target_image = images[-1, :, :, :]
  target_camera = cameras[-1, :]
  target_caption = captions[-1]

  query = ((context_image, context_camera, context_caption), target_camera)
  target = (target_image, target_caption, top_down)
  return query, target