code: def tsne(
      input_matrix: Union[pd.Series, pd.DataFrame],
      n_components=2,
      perplexity=30.0,
      learning_rate=200.0,
      n_iter=1000,
      random_state=None,
      n_jobs=-1,
  ) -> VectorSeries:
      """
      Performs t-Distributed Stochastic Neighbor Embedding on the given
      input.
  
      t-distributed Stochastic Neighbor Embedding (t-SNE) is
      a machine learning algorithm used to visualize high-dimensional data
      in fewer dimensions. In natural language processing, the
      high-dimensional data is usually a document-term matrix (so in
      texthero usually a Series after applying
      :meth:`texthero.representation.tfidf` or some other first
      representation function that assigns a scalar (a weight) to each word)
      that is hard to visualize as there might be many terms. With t-SNE,
      every document gets a new, low-dimensional (n_components entries)
      vector in such a way that the differences / similarities between
      documents are preserved.
  
      T-SNE can directly handle sparse input, so when calling tsne on a
      sparse DataFrame, the advantage of sparseness is kept.
  
      Parameters
      ----------
      input_matrix : Pandas Series (VectorSeries) or DataFrame
  
      n_components : int, optional, default=2
          Number of components to keep (dimensionality of output vectors).
          If n_components is not set or None, all components are kept.
  
      perplexity : float, optional, default=30
          The perplexity is related to the number of nearest neighbors that
          is used in other manifold learning algorithms. Larger datasets
          usually require a larger perplexity. Consider selecting a value
          between 5 and 50. Different values can result in significanlty
          different results.
  
      learning_rate : float, optional, default=200.0
          The learning rate for t-SNE is usually in the range [10.0, 1000.0]. If
          the learning rate is too high, the data may look like a 'ball' with any
          point approximately equidistant from its nearest neighbours. If the
          learning rate is too low, most points may look compressed in a dense
          cloud with few outliers. If the cost function gets stuck in a bad local
          minimum increasing the learning rate may help.
  
      n_iter : int, optional, default=1000
          Maximum number of iterations for the optimization. Should be at
          least 250.
  
      random_state : int, optional, default=None
          Determines the random number generator. Pass an int for reproducible
          results across multiple function calls.
  
      n_jobs : int, optional, default=-1
          The number of parallel jobs to run for neighbors search.
          ``-1`` means using all processors.
  
      Returns
      -------
      Pandas Series with the vector calculated by t-SNE for the document in
      every cell.
  
      Examples
      --------
      >>> import texthero as hero
      >>> import pandas as pd
      >>> s = pd.Series(["Football, Sports, Soccer",
      ...              "Music, Violin, Orchestra",  "Football, Music"])
      >>> s = s.pipe(hero.clean).pipe(hero.tokenize).pipe(hero.term_frequency)
      >>> hero.tsne(s, random_state=42) # doctest: +SKIP
      0      [-18.833383560180664, -276.800537109375]
      1     [-210.60179138183594, 143.00535583496094]
      2    [-478.27984619140625, -232.97410583496094]
      dtype: object
  
      See also
      --------
      `t-SNE on Wikipedia <https://en.wikipedia.org/wiki/T-distributed_
      stochastic_neighbor_embedding>`_
  
      """
      # Default n_components=2 to enable users to easily plot the results.
      tsne = TSNE(
          n_components=n_components,
          perplexity=perplexity,
          learning_rate=learning_rate,
          n_iter=n_iter,
          random_state=random_state,
          n_jobs=n_jobs,
      )
  
      if isinstance(input_matrix, pd.DataFrame):
          input_matrix_coo = input_matrix.sparse.to_coo()
          input_matrix_for_vectorization = input_matrix_coo.astype(
              "float64"
          )
      else:
          input_matrix_for_vectorization = list(input_matrix)
  
      return pd.Series(
          list(tsne.fit_transform(input_matrix_for_vectorization)),
          index=input_matrix.index,
      )
  
imports: import pandas
  import numpy
  from sklearn.feature_extraction.text import TfidfVectorizer, CountVectorizer
  from sklearn.manifold import TSNE
  from sklearn.decomposition import PCA, NMF
  from sklearn.cluster import KMeans, DBSCAN, MeanShift
  from sklearn.metrics.pairwise import cosine_similarity
  from sklearn.preprocessing import normalize
  from scipy.sparse import coo_matrix
  from typing import Optional, Union, Any
  from texthero._types import TextSeries, TokenSeries, VectorSeries, DataFrame, InputSeries
  from texthero import preprocessing
  import logging
  import warnings
label_desc: Use image node_id 6 for calling a global function with example usage: tsne(input_matrix, n_components, perplexity, learning_rate, n_iter, random_state, n_jobs) and returns: pd