class_docstr: Simple encoder that assigns a unique integer to every observed label.
  
  Allocates an `unknown` label by default to index 0.
  
  Labels must be exact matches between inference and training (e.g. no .lower() on strings is performed here).
class_docstr_tok: ["Simple","encoder","that","assigns","a","unique","integer","to","every","observed","label",".","Allocates","an","`","unknown","`","label","by","default","to","index","0",".","Labels","must","be","exact","matches","between","inference","and","training","(","e.g",".","no",".lower","(",")","on","strings","is","performed","here",")","."]
docstr: :param normalize: can be used to temporarily return unnormalized values
docstr_tok: [":","param","normalize",":","can","be","used","to","temporarily","return","unnormalized","values"]
code: def encode(
      self, data: Union[tuple, np.ndarray, pd.Series], normalize=True
  ) -> torch.Tensor:
      """
      :param normalize: can be used to temporarily return unnormalized values
      """
      if not isinstance(data, pd.Series):
          data = pd.Series(
              data
          )  # specific to the Gym class - remove once deprecated!
      if isinstance(data, np.ndarray):
          data = pd.Series(data)
  
      data = data.astype(str)
      encoded = torch.Tensor(data.map(self.label_map))
  
      if normalize and self.normalize:
          encoded /= self.n_labels
      if len(encoded.shape) < 2:
          encoded = encoded.unsqueeze(-1)
  
      return encoded
  
file_path: lightwood/lightwood/encoder/categorical/simple_label.py
imports: from typing import List, Union
  from collections import defaultdict
  import pandas
  import numpy
  import torch
  from lightwood.encoder.base import BaseEncoder
  from lightwood.helpers.constants import _UNCOMMON_WORD
label_desc: Use image node_id 3 for calling the SimpleLabelEncoder obj's underlying member method code with example usage: obj.encode(data, normalize) and returns: encoded