def tospark(self, engine=None):
        """
        Convert to distributed spark mode.
        """
        from thunder.images.readers import fromarray

        if self.mode == 'spark':
            logging.getLogger('thunder').warn('images already in spark mode')
            pass

        if engine is None:
            raise ValueError('Must provide a SparkContext')

        return fromarray(self.toarray(), engine=engine)
Convert to distributed spark mode.