<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def _compare(img_spec1, img_spec2, num_rows=2, num_cols=6, mixer='checker_board', rescale_method='global', annot=None, padding=5, bkground_thresh=0.05, output_path=None, figsize=None, **kwargs):
 """ Produces checkerboard comparison plot of two 3D images. Parameters img_spec1 : str or nibabel image-like object MR image (or path to one) to be visualized img_spec2 : str or nibabel image-like object MR image (or path to one) to be visualized num_rows : int number of rows (top to bottom) per each of 3 dimensions num_cols : int number of panels (left to right) per row of each dimension. mixer : str type of mixer to produce the comparison figure. Options: checker_board, color_mix, diff_abs, rescale_method : bool or str or list or None Method to rescale the intensity values to. Choices : 'global', 'each', False or None. Default: 'global', min and max values computed based on ranges from both images. If 'each', rescales each image separately to [0, 1]. This option is useful when overlaying images with very different intensity ranges e.g. from different modalities altogether. If False or None, no rescaling is done (does not work yet). annot : str Text to display to annotate the visualization padding : int number of voxels to pad around each panel. output_path : str path to save the generate collage to. figsize : list Size of figure in inches to be passed on to plt.figure() e.g. [12, 12] or [20, 20] kwargs : dict Additional arguments specific to the particular mixer e.g. alpha_channels = [1, 1] for the color_mix mixer Returns ------- """


    num_rows, num_cols, padding = check_params(num_rows, num_cols, padding)

    img1, img2 = check_images(img_spec1, img_spec2, bkground_thresh=bkground_thresh)
    img1, img2 = crop_to_extents(img1, img2, padding)

    num_slices_per_view = num_rows * num_cols
    slices = pick_slices(img2, num_slices_per_view)

    rescale_images, img1, img2, min_value, max_value = check_rescaling(img1, img2, rescale_method)

    plt.style.use('dark_background')

    num_axes = 3
    if figsize is None:
        figsize = [3 * num_axes * num_rows, 3 * num_cols]
    fig, ax = plt.subplots(num_axes * num_rows, num_cols, figsize=figsize)

    # displaying some annotation text if provided
    # good choice would be the location of the input images (for future refwhen image is shared or misplaced!)
    if annot is not None:
        fig.suptitle(annot, backgroundcolor='black', color='g')

    display_params = dict(interpolation='none', aspect='equal', origin='lower')

    ax = ax.flatten()
    ax_counter = 0
    for dim_index in range(3):
        for slice_num in slices[dim_index]:
            plt.sca(ax[ax_counter])
            ax_counter = ax_counter + 1

            slice1 = get_axis(img1, dim_index, slice_num)
            slice2 = get_axis(img2, dim_index, slice_num)

            mixed, mixer_spec_params = _generic_mixer(slice1, slice2, mixer, **kwargs)
            display_params.update(mixer_spec_params)

            plt.imshow(mixed, vmin=min_value, vmax=max_value, **display_params)

            # adjustments for proper presentation
            plt.axis('off')

    fig.tight_layout()

    if output_path is not None:
        output_path = output_path.replace(' ', '_')
        fig.savefig(output_path + '.png', bbox_inches='tight')

    # plt.close()

    return fig