code: def encode_text_vectors(
      self,
      texts,
      pca_dims=50,
      tsne_dims=None,
      tsne_seed=None,
      return_pca=False,
      return_tsne=False,
  ):
      # if a single text, force it into a list:
      if isinstance(texts, str):
          texts = [texts]
  
      vector_output = Model(
          inputs=self.model.input,
          outputs=self.model.get_layer("attention").output,
      )
      encoded_vectors = []
      maxlen = self.config["max_length"]
      for text in texts:
          if self.config["word_level"]:
              text = text_to_word_sequence(text, filters="")
          text_aug = [self.META_TOKEN] + list(text[0:maxlen])
          encoded_text = textgenrnn_encode_sequence(
              text_aug, self.vocab, maxlen
          )
          encoded_vector = vector_output.predict(encoded_text)
          encoded_vectors.append(encoded_vector)
  
      encoded_vectors = np.squeeze(np.array(encoded_vectors), axis=1)
      if pca_dims is not None:
          assert len(texts) > 1, "Must use more than 1 text for PCA"
          pca = PCA(pca_dims)
          encoded_vectors = pca.fit_transform(encoded_vectors)
  
      if tsne_dims is not None:
          tsne = TSNE(tsne_dims, random_state=tsne_seed)
          encoded_vectors = tsne.fit_transform(encoded_vectors)
  
      return_objects = encoded_vectors
      if return_pca or return_tsne:
          return_objects = [return_objects]
      if return_pca:
          return_objects.append(pca)
      if return_tsne:
          return_objects.append(tsne)
  
      return return_objects
  
imports: import json
  import re
  import numpy
  import tensorflow
  import tqdm
  from pkg_resources import resource_filename
  from sklearn.decomposition import PCA
  from sklearn.manifold import TSNE
  from sklearn.metrics.pairwise import cosine_similarity
  from sklearn.preprocessing import LabelBinarizer
  from tensorflow import config
  from tensorflow.compat.v1.keras.backend import set_session
  from tensorflow.keras.callbacks import LearningRateScheduler
  from tensorflow.keras.models import Model
  from tensorflow.keras.optimizers import Adam
  from tensorflow.keras.preprocessing.text import Tokenizer, text_to_word_sequence
  from .model import textgenrnn_model
  from .model_training import generate_sequences_from_texts
  from .utils import generate_after_epoch, save_model_weights, textgenrnn_encode_sequence, textgenrnn_generate, textgenrnn_texts_from_file, textgenrnn_texts_from_file_context
label_desc: Use image node_id 12 for calling the textgenrnn obj's underlying member method code with example usage: obj.encode_text_vectors(texts, pca_dims, tsne_dims, tsne_seed, return_pca, return_tsne) and returns: return_objects