class_docstr: Class implements torch model for classification of texts.
  Input can either be embedded tokenized texts OR indices of words in the vocabulary.
  Number of tokens is not fixed while the samples in batch should be padded to the same (e.g. longest) lengths.
  
  Args:
      n_classes: number of classes
      kernel_sizes_cnn: list of kernel sizes of convolutions
      filters_cnn: number of filters for convolutions
      dense_size: number of units for dense layer
      dropout_rate: dropout rate, after convolutions and between dense
      embedding_size: size of vector representation of words
      multilabel: is multi-label classification (if so, `sigmoid` activation will be used, otherwise, softmax)
      criterion: criterion name from `torch.nn`
      embedded_tokens: True, if input contains embedded tokenized texts;
                       False, if input containes indices of words in the vocabulary
      vocab_size: vocabulary size in case of `embedded_tokens=False`, and embedding is a layer in the Network
      return_probas: whether to return probabilities or index of classes (only for `multilabel=False`)
  
  Attributes:
      model: torch model itself
      epochs_done: number of epochs that were done
      criterion: torch criterion instance
class_docstr_tok: ["Class","implements","torch","model","for","classification","of","texts",".","Input","can","either","be","embedded","tokenized","texts","OR","indices","of","words","in","the","vocabulary",".","Number","of","tokens","is","not","fixed","while","the","samples","in","batch","should","be","padded","to","the","same","(","e.g",".","longest",")","lengths",".","Args",":","n_classes",":","number","of","classes","kernel_sizes_cnn",":","list","of","kernel","sizes","of","convolutions","filters_cnn",":","number","of","filters","for","convolutions","dense_size",":","number","of","units","for","dense","layer","dropout_rate",":","dropout","rate",",","after","convolutions","and","between","dense","embedding_size",":","size","of","vector","representation","of","words","multilabel",":","is","multi-label","classification","(","if","so",",","`","sigmoid","`","activation","will","be","used",",","otherwise",",","softmax",")","criterion",":","criterion","name","from","`","torch.nn","`","embedded_tokens",":","True",",","if","input","contains","embedded","tokenized","texts",";","False",",","if","input","containes","indices","of","words","in","the","vocabulary","vocab_size",":","vocabulary","size","in","case","of","`","embedded_tokens=False","`",",","and","embedding","is","a","layer","in","the","Network","return_probas",":","whether","to","return","probabilities","or","index","of","classes","(","only","for","`","multilabel=False","`",")","Attributes",":","model",":","torch","model","itself","epochs_done",":","number","of","epochs","that","were","done","criterion",":","torch","criterion","instance"]
code: def __init__(
      self,
      n_classes: int,
      kernel_sizes_cnn: List[int],
      filters_cnn: int,
      dense_size: int,
      dropout_rate: float = 0.0,
      embedding_size: Optional[int] = None,
      multilabel: bool = False,
      criterion: str = "CrossEntropyLoss",
      embedded_tokens: bool = True,
      vocab_size: Optional[int] = None,
      return_probas: bool = True,
      **kwargs,
  ):
      if n_classes == 0:
          raise ConfigError(
              "Please, provide vocabulary with considered classes or number of classes."
          )
  
      if multilabel and not return_probas:
          raise RuntimeError(
              "Set return_probas to True for multilabel classification!"
          )
  
      self.multilabel = multilabel
      self.return_probas = return_probas
      model = ShallowAndWideCnn(
          n_classes=n_classes,
          embedding_size=embedding_size,
          kernel_sizes_cnn=kernel_sizes_cnn,
          filters_cnn=filters_cnn,
          dense_size=dense_size,
          dropout_rate=dropout_rate,
          embedded_tokens=embedded_tokens,
          vocab_size=vocab_size,
      )
      self.criterion = getattr(torch.nn, criterion)()
      super().__init__(model, **kwargs)
  
file_path: DeepPavlov/deeppavlov/models/classifiers/torch_classification_model.py
imports: import logging
  from typing import List, Union, Optional
  import numpy
  import torch
  from deeppavlov.core.common.errors import ConfigError
  from deeppavlov.core.common.registry import register
  from deeppavlov.core.models.torch_model import TorchModel
  from .torch_nets import ShallowAndWideCnn
label_desc: Use image node_id 1 to create a new TorchTextClassificationModel object from inherited base classes: TorchModel with example: obj = TorchTextClassificationModel(n_classes, kernel_sizes_cnn, filters_cnn, dense_size, dropout_rate, embedding_size, multilabel, criterion, embedded_tokens, vocab_size, return_probas)