def METHOD_NAME(self, raw_X):
    """Transform a sequence of instances to a scipy.sparse matrix.
    Parameters
    ----------
    raw_X : iterable over iterable over raw features, length = n_samples
        Samples. Each sample must be iterable an (e.g., a list or tuple)
        containing/generating feature names (and optionally values, see
        the input_type constructor argument) which will be hashed.
        raw_X need not support the len function, so it can be the result
        of a generator; n_samples is determined on the fly.
    Returns
    -------
    X : sparse matrix of shape (n_samples, n_features)
        Feature matrix, for use with estimators or further transformers.
    """
    raw_X = iter(raw_X)
    if self.input_type == "dict":
        raw_X = (_iteritems(d) for d in raw_X)
    elif self.input_type == "string":
        first_raw_X = next(raw_X)
        if isinstance(first_raw_X, str):
            raise ValueError(
                "Samples can not be a single string. The input must be an iterable"
                " over iterables of strings."
            )
        raw_X_ = chain([first_raw_X], raw_X)
        raw_X = (((f, 1) for f in x) for x in raw_X_)
    indices, indptr, values = _hashing_transform(
        raw_X, self.n_features, self.dtype, self.alternate_sign, seed=0
    )
    n_samples = indptr.shape[0] - 1
    if n_samples == 0:
        raise ValueError("Cannot vectorize empty sequence.")
    X = sp.csr_matrix(
        (values, indices, indptr),
        dtype=self.dtype,
        shape=(n_samples, self.n_features),
    )
    X.sum_duplicates()  # also sorts the indices
    return X