<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def plot_latent_scatter(self, labels=None, which_indices=None, legend=True, plot_limits=None, marker='<>^vsd', num_samples=1000, projection='2d', **kwargs):
 """ Plot a scatter plot of the latent space. :param array-like labels: a label for each data point (row) of the inputs :param (int, int) which_indices: which input dimensions to plot against each other :param bool legend: whether to plot the legend on the figure :param plot_limits: the plot limits for the plot :type plot_limits: (xmin, xmax, ymin, ymax) or ((xmin, xmax), (ymin, ymax)) :param str marker: markers to use - cycle if more labels then markers are given :param kwargs: the kwargs for the scatter plots """

    canvas, projection, kwargs, sig_dims = _new_canvas(self, projection, kwargs, which_indices)

    X, _, _ = get_x_y_var(self)
    if labels is None:
        labels = np.ones(self.num_data)
        legend = False
    else:
        legend = find_best_layout_for_subplots(len(np.unique(labels)))[1]
    scatters = _plot_latent_scatter(canvas, X, sig_dims, labels, marker, num_samples, projection=projection, **kwargs)
    return pl().add_to_canvas(canvas, dict(scatter=scatters), legend=legend)