def __init__(self, galaxies, image_plane_grid_stack, border=None, cosmology=cosmo.Planck15):
plane_redshifts = lens_util.ordered_plane_redshifts_from_galaxies(galaxies=galaxies)<EOL>galaxies_in_planes =lens_util.galaxies_in_redshift_ordered_planes_from_galaxies(galaxies=galaxies,<EOL>plane_redshifts=plane_redshifts)<EOL>image_plane_grid_stack = pix.setup_image_plane_pixelization_grid_from_galaxies_and_grid_stack(<EOL>galaxies=galaxies, grid_stack=image_plane_grid_stack)<EOL>planes = []<EOL>for plane_index in range(<NUM_LIT:0>, len(plane_redshifts)):<EOL><INDENT>compute_deflections = lens_util.compute_deflections_at_next_plane(plane_index=plane_index,<EOL>total_planes=len(plane_redshifts))<EOL>new_grid_stack = image_plane_grid_stack<EOL>if plane_index > <NUM_LIT:0>:<EOL><INDENT>for previous_plane_index in range(plane_index):<EOL><INDENT>scaling_factor = cosmology_util.scaling_factor_between_redshifts_from_redshifts_and_cosmology(<EOL>redshift_0=plane_redshifts[previous_plane_index], redshift_1=plane_redshifts[plane_index],<EOL>redshift_final=plane_redshifts[-<NUM_LIT:1>], cosmology=cosmology)<EOL>scaled_deflection_stack = lens_util.scaled_deflection_stack_from_plane_and_scaling_factor(<EOL>plane=planes[previous_plane_index], scaling_factor=scaling_factor)<EOL>new_grid_stack =lens_util.grid_stack_from_deflection_stack(grid_stack=new_grid_stack,<EOL>deflection_stack=scaled_deflection_stack)<EOL><DEDENT><DEDENT>planes.append(pl.Plane(galaxies=galaxies_in_planes[plane_index], grid_stack=new_grid_stack,<EOL>border=border, compute_deflections=compute_deflections, cosmology=cosmology))<EOL><DEDENT>super(TracerMultiPlanes, self).__init__(planes=planes, cosmology=cosmology)<EOL>
Ray-tracer for a lens system with any number of planes.

        The redshift of these planes are specified by the redshits of the galaxies; there is a unique plane redshift \
        for every unique galaxy redshift (galaxies with identical redshifts are put in the same plane).

        To perform multi-plane ray-tracing, a cosmology must be supplied so that deflection-angles can be rescaled \
        according to the lens-geometry of the multi-plane system. All galaxies input to the tracer must therefore \
        have redshifts.

        This tracer has only one grid-stack (see grid_stack.GridStack) which is used for ray-tracing.

        Parameters
        ----------
        galaxies : [Galaxy]
            The list of galaxies in the ray-tracing calculation.
        image_plane_grid_stack : grid_stacks.GridStack
            The image-plane grid stack which is traced. (includes the regular-grid, sub-grid, blurring-grid, etc.).
        border : masks.RegularGridBorder
            The border of the regular-grid, which is used to relocate demagnified traced pixels to the \
            source-plane borders.
        cosmology : astropy.cosmology
            The cosmology of the ray-tracing calculation.