class_docstr: The ``TextClassifier`` is a :class:`~flash.Task` for classifying text. For more details, see
  :ref:`text_classification`. The ``TextClassifier`` also supports multi-label classification with
  ``multi_label=True``. For more details, see :ref:`text_classification_multi_label`.
  
  Args:
      num_classes: Number of classes to classify.
      backbone: A model to use to compute text features can be any BERT model from HuggingFace/transformersimage.
      max_length: The maximum length to pad / truncate sequences to.
      optimizer: Optimizer to use for training.
      lr_scheduler: The LR scheduler to use during training.
      metrics: Metrics to compute for training and evaluation. Can either be an metric from the `torchmetrics`
          package, a custom metric inherenting from `torchmetrics.Metric`, a callable function or a list/dict
          containing a combination of the aforementioned. In all cases, each metric needs to have the signature
          `metric(preds,target)` and return a single scalar tensor. Defaults to :class:`torchmetrics.Accuracy`.
      learning_rate: Learning rate to use for training, defaults to `1e-3`
      multi_label: Whether the targets are multi-label or not.
      enable_ort: Enable Torch ONNX Runtime Optimization: https://onnxruntime.ai/docs/#onnx-runtime-for-training
class_docstr_tok: ["The","``","TextClassifier","``","is","a",":","class",":","`","~flash.Task","`","for","classifying","text",".","For","more","details",",","see",":","ref",":","`","text_classification","`",".","The","``","TextClassifier","``","also","supports","multi-label","classification","with","``","multi_label=True","``",".","For","more","details",",","see",":","ref",":","`","text_classification_multi_label","`",".","Args",":","num_classes",":","Number","of","classes","to","classify",".","backbone",":","A","model","to","use","to","compute","text","features","can","be","any","BERT","model","from","HuggingFace\/transformersimage",".","max_length",":","The","maximum","length","to","pad","\/","truncate","sequences","to",".","optimizer",":","Optimizer","to","use","for","training",".","lr_scheduler",":","The","LR","scheduler","to","use","during","training",".","metrics",":","Metrics","to","compute","for","training","and","evaluation",".","Can","either","be","an","metric","from","the","`","torchmetrics","`","package",",","a","custom","metric","inherenting","from","`","torchmetrics.Metric","`",",","a","callable","function","or","a","list\/dict","containing","a","combination","of","the","aforementioned",".","In","all","cases",",","each","metric","needs","to","have","the","signature","`","metric","(","preds",",","target",")","`","and","return","a","single","scalar","tensor",".","Defaults","to",":","class",":","`","torchmetrics.Accuracy","`",".","learning_rate",":","Learning","rate","to","use","for","training",",","defaults","to","`","1e-3","`","multi_label",":","Whether","the","targets","are","multi-label","or","not",".","enable_ort",":","Enable","Torch","ONNX","Runtime","Optimization",":","https",":","\/\/onnxruntime.ai\/docs\/","#","onnx-runtime-for-training"]
docstr: This function is used only for debugging usage with CI.
docstr_tok: ["This","function","is","used","only","for","debugging","usage","with","CI","."]
code: def _ci_benchmark_fn(self, history: List[Dict[str, Any]]):
      """This function is used only for debugging usage with CI."""
      if self.hparams.multi_label:
          assert history[-1]["val_f1score"] > 0.40, history[-1][
              "val_f1score"
          ]
      else:
          assert history[-1]["val_accuracy"] > 0.70, history[-1][
              "val_accuracy"
          ]
  
file_path: lightning-flash/src/flash/text/classification/model.py
imports: from typing import Any, Dict, List, Optional, Type, Union
  from pytorch_lightning import Callback
  from flash.core.classification import ClassificationAdapterTask
  from flash.core.data.io.input import ServeInput
  from flash.core.data.io.input_transform import InputTransform
  from flash.core.data.io.output import Output
  from flash.core.registry import FlashRegistry
  from flash.core.serve import Composition
  from flash.core.utilities.imports import requires
  from flash.core.utilities.types import INPUT_TRANSFORM_TYPE, LOSS_FN_TYPE, LR_SCHEDULER_TYPE, METRICS_TYPE, OPTIMIZER_TYPE
  from flash.text.classification.backbones import TEXT_CLASSIFIER_BACKBONES
  from flash.text.input import TextDeserializer
  from flash.text.ort_callback import ORTCallback
label_desc: Use image node_id 2 for calling the TextClassifier obj's underlying member method code with example usage: obj._ci_benchmark_fn(history) without return types