class_docstr: Class implements fastText embedding model
  
  Args:
      load_path: path where to load pre-trained embedding model from
      pad_zero: whether to pad samples or not
  
  Attributes:
      model: model instance
      tok2emb: dictionary with already embedded tokens
      dim: dimension of embeddings
      pad_zero: whether to pad sequence of tokens with zeros or not
      mean: whether to return one mean embedding vector per sample
      load_path: path with pre-trained fastText binary model
class_docstr_tok: ["Class","implements","fastText","embedding","model","Args",":","load_path",":","path","where","to","load","pre-trained","embedding","model","from","pad_zero",":","whether","to","pad","samples","or","not","Attributes",":","model",":","model","instance","tok2emb",":","dictionary","with","already","embedded","tokens","dim",":","dimension","of","embeddings","pad_zero",":","whether","to","pad","sequence","of","tokens","with","zeros","or","not","mean",":","whether","to","return","one","mean","embedding","vector","per","sample","load_path",":","path","with","pre-trained","fastText","binary","model"]
docstr: Embed one text sample
  
  Args:
      tokens: tokenized text sample
      mean: whether to return mean embedding of tokens per sample
  
  Returns:
      list of embedded tokens or array of mean values
docstr_tok: ["Embed","one","text","sample","Args",":","tokens",":","tokenized","text","sample","mean",":","whether","to","return","mean","embedding","of","tokens","per","sample","Returns",":","list","of","embedded","tokens","or","array","of","mean","values"]
code: def _encode(
      self, tokens: List[str], mean: bool
  ) -> Union[List[np.ndarray], np.ndarray]:
      """
      Embed one text sample
  
      Args:
          tokens: tokenized text sample
          mean: whether to return mean embedding of tokens per sample
  
      Returns:
          list of embedded tokens or array of mean values
      """
      embedded_tokens = []
      for t in tokens:
          try:
              emb = self.tok2emb[t]
          except KeyError:
              try:
                  emb = self._get_word_vector(t)
              except KeyError:
                  emb = np.zeros(self.dim, dtype=np.float32)
              self.tok2emb[t] = emb
          embedded_tokens.append(emb)
  
      if mean is None:
          mean = self.mean
  
      if mean:
          filtered = [et for et in embedded_tokens if np.any(et)]
          if filtered:
              return np.mean(filtered, axis=0)
          return np.zeros(self.dim, dtype=np.float32)
  
      return embedded_tokens
  
file_path: DeepPavlov/deeppavlov/models/embedders/abstract_embedder.py
imports: from abc import ABCMeta, abstractmethod
  from logging import getLogger
  from pathlib import Path
  from typing import List, Union, Iterator
  import numpy
  from deeppavlov.core.data.utils import zero_pad
  from deeppavlov.core.models.component import Component
  from deeppavlov.core.models.serializable import Serializable
label_desc: Use image node_id 6 for calling the Embedder obj's underlying member method code with example usage: obj._encode(tokens, mean) and returns: embedded_tokens, np, np