class_docstr: One-hot featurizer with zero-padding.
  If ``single_vector``, return the only vector per sample which can have several elements equal to ``1``.
  
  Parameters:
      depth: the depth for one-hotting
      pad_zeros: whether to pad elements of batch with zeros
      single_vector: whether to return one vector for the sample (sum of each one-hotted vectors)
class_docstr_tok: ["One-hot","featurizer","with","zero-padding",".","If","``","single_vector","``",",","return","the","only","vector","per","sample","which","can","have","several","elements","equal","to","``","1","``",".","Parameters",":","depth",":","the","depth","for","one-hotting","pad_zeros",":","whether","to","pad","elements","of","batch","with","zeros","single_vector",":","whether","to","return","one","vector","for","the","sample","(","sum","of","each","one-hotted","vectors",")"]
docstr: Convert given batch of list of labels to one-hot representation of the batch.
  
  Args:
      batch: list of samples, where each sample is a list of integer labels.
      **kwargs: additional arguments
  
  Returns:
      if ``single_vector``, list of one-hot representations of each sample,
      otherwise, list of lists of one-hot representations of each label in a sample
docstr_tok: ["Convert","given","batch","of","list","of","labels","to","one-hot","representation","of","the","batch",".","Args",":","batch",":","list","of","samples",",","where","each","sample","is","a","list","of","integer","labels",".","*","*","kwargs",":","additional","arguments","Returns",":","if","``","single_vector","``",",","list","of","one-hot","representations","of","each","sample",",","otherwise",",","list","of","lists","of","one-hot","representations","of","each","label","in","a","sample"]
code: def __call__(
      self, batch: List[List[int]], **kwargs
  ) -> Union[List[List[np.ndarray]], List[np.ndarray]]:
      """
      Convert given batch of list of labels to one-hot representation of the batch.
  
      Args:
          batch: list of samples, where each sample is a list of integer labels.
          **kwargs: additional arguments
  
      Returns:
          if ``single_vector``, list of one-hot representations of each sample,
          otherwise, list of lists of one-hot representations of each label in a sample
      """
      one_hotted_batch = []
  
      for utt in batch:
          if isinstance(utt, Iterable):
              one_hotted_utt = self._to_one_hot(utt, self._depth)
          elif isinstance(utt, int):
              if self._pad_zeros or self.single_vector:
                  one_hotted_utt = self._to_one_hot([utt], self._depth)
              else:
                  one_hotted_utt = self._to_one_hot(
                      [utt], self._depth
                  ).reshape(-1)
  
          if self.single_vector:
              one_hotted_utt = np.sum(one_hotted_utt, axis=0)
  
          one_hotted_batch.append(one_hotted_utt)
  
      if self._pad_zeros:
          one_hotted_batch = zero_pad(one_hotted_batch)
      return one_hotted_batch
  
file_path: DeepPavlov/deeppavlov/models/preprocessors/one_hotter.py
imports: from typing import List, Union, Iterable
  import numpy
  from deeppavlov.core.common.errors import ConfigError
  from deeppavlov.core.common.registry import register
  from deeppavlov.core.data.utils import zero_pad
  from deeppavlov.core.models.component import Component
label_desc: Use image node_id 2 for calling the OneHotter obj's underlying member method code with example usage: obj.__call__(batch) and returns: one_hotted_batch