<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def _baseplot(cls, session, type, *args, **kwargs):
 """ Base method for plotting data and images. Applies a plot-type specific cleaning operation to generate a dictionary with the data, then creates a visualization with the data. Expects a session and a type, followed by all plot-type specific positional and keyword arguments, which will be handled by the clean method of the given plot type. If the dictionary contains only images, or only non-image data, they will be passed on their own. If the dictionary contains both images and non-image data, the images will be appended to the visualization. """


        if not type:
            raise Exception("Must provide a plot type")

        options, description = cls._clean_options(**kwargs)
        data = cls._clean_data(*args)

        if 'images' in data and len(data) > 1:
            images = data['images']
            del data['images']
            viz = cls._create(session, data=data, type=type, options=options, description=description)
            first_image, remaining_images = images[0], images[1:]
            viz._append_image(first_image)
            for image in remaining_images:
                viz._append_image(image)

        elif 'images' in data:
            images = data['images']
            viz = cls._create(session, images=images, type=type, options=options, description=description)

        else:
            viz = cls._create(session, data=data, type=type, options=options, description=description)

        return viz