def random_subset(self, number, new_collection, **kwargs):
        """
        Produces a random subset of a given collection and inserts it into a new collection.

        | Arguments:
        | ``new_collection`` -- The name of the collection to insert the new values into.  
            Any existing values will be deleted.
            If `None`, the subset is stored to the current collection.

        | Keyword arguments:
        | ``create_if_missing`` -- when False a ValueError is raised if the new collection doesn't exist
        | ``error_if_exists`` -- When True a ValueError is raised if the new collection already exists 
        """
        collection = None
        if new_collection in [None, self.name]:
            collection = self
            random.shuffle(self.keys)
            for key in self.keys[number:]:
                self.db.delete(key)
            self.keys = self.keys[:number]
            list.sort(self.keys)

        else:
            new_keys = copy.copy(self.keys)
            random.shuffle(new_keys)
            new_keys = new_keys[:number]
            list.sort(new_keys)
            collection = self.parent_db.collection(new_collection, **kwargs)
            collection.delete_all()
            for key in new_keys:
                collection.append(decode(self.db.get(key)))

        return collection
dataset/ETHPy150Open corbt/pypeline/pypeline/DB.py/Collection.random_subset/original