class_docstr: Displays a classification label, along with confidence scores of top categories, if provided.
  Preprocessing: this component does *not* accept input.
  Postprocessing: expects a {Dict[str, float]} of classes and confidences, or {str} with just the class or an {int}/{float} for regression outputs, or a {str} path to a .json file containing a json dictionary in the structure produced by Label.postprocess().
  
  Demos: main_note, titanic_survival
  Guides: image-classification-in-pytorch, image-classification-in-tensorflow, image-classification-with-vision-transformers
class_docstr_tok: ["Displays","a","classification","label",",","along","with","confidence","scores","of","top","categories",",","if","provided",".","Preprocessing",":","this","component","does","*","not","*","accept","input",".","Postprocessing",":","expects","a","{","Dict","[","str",",","float","]","}","of","classes","and","confidences",",","or","{","str","}","with","just","the","class","or","an","{","int","}","\/","{","float","}","for","regression","outputs",",","or","a","{","str","}","path","to","a",".json","file","containing","a","json","dictionary","in","the","structure","produced","by","Label.postprocess","(",")",".","Demos",":","main_note",",","titanic_survival","Guides",":","image-classification-in-pytorch",",","image-classification-in-tensorflow",",","image-classification-with-vision-transformers"]
code: def preprocess(
      self, payload: LabelData | None
  ) -> dict[str, float] | str | float | None:
      if payload is None:
          return None
      if payload.confidences is None:
          return payload.label
      return {
          d["label"]: d["confidence"]
          for d in payload.model_dump()["confidences"]
      }
  
file_path: gradio/gradio/components/label.py
imports: from __future__ import annotations
  import json
  import operator
  from pathlib import Path
  from typing import Any, Callable, List, Optional, Union
  from gradio_client.documentation import document, set_documentation_group
  from gradio.components.base import Component
  from gradio.data_classes import GradioModel
  from gradio.events import Events
label_desc: Use image node_id 3 for calling the Label obj's underlying member method code with example usage: obj.preprocess(payload) and returns: unknown, None, payload