docstr: Adds a new task to an existing TARS model.
  
  Sets necessary attributes and finally 'switches' to the new task. Parameters are similar to the constructor
  except for model choice, batch size and negative sampling. This method does not store the resultant model onto
  disk.
  
  Args:
      task_name: a string depicting the name of the task
      label_dictionary: dictionary of the labels you want to predict
      label_type: string to identify the label type ('ner', 'sentiment', etc.)
      multi_label: whether this task is a multi-label prediction problem
      force_switch: if True, will overwrite existing task with same name
docstr_tok: ["Adds","a","new","task","to","an","existing","TARS","model",".","Sets","necessary","attributes","and","finally","'switches","'","to","the","new","task",".","Parameters","are","similar","to","the","constructor","except","for","model","choice",",","batch","size","and","negative","sampling",".","This","method","does","not","store","the","resultant","model","onto","disk",".","Args",":","task_name",":","a","string","depicting","the","name","of","the","task","label_dictionary",":","dictionary","of","the","labels","you","want","to","predict","label_type",":","string","to","identify","the","label","type","(","'ner","'",",","'sentiment","'",",","etc",".",")","multi_label",":","whether","this","task","is","a","multi-label","prediction","problem","force_switch",":","if","True",",","will","overwrite","existing","task","with","same","name"]
code: def add_and_switch_to_new_task(
      self,
      task_name: str,
      label_dictionary: Union[List, Set, Dictionary, str],
      label_type: str,
      multi_label: bool = True,
      force_switch: bool = False,
  ):
      """Adds a new task to an existing TARS model.
  
      Sets necessary attributes and finally 'switches' to the new task. Parameters are similar to the constructor
      except for model choice, batch size and negative sampling. This method does not store the resultant model onto
      disk.
  
      Args:
          task_name: a string depicting the name of the task
          label_dictionary: dictionary of the labels you want to predict
          label_type: string to identify the label type ('ner', 'sentiment', etc.)
          multi_label: whether this task is a multi-label prediction problem
          force_switch: if True, will overwrite existing task with same name
      """
      if (
          task_name in self._task_specific_attributes
          and not force_switch
      ):
          log.warning(
              f"Task `{task_name}` already exists in TARS model. Switching to it."
          )
      else:
          # make label dictionary if no Dictionary object is passed
          if isinstance(label_dictionary, Dictionary):
              label_dictionary = label_dictionary.get_items()
          if isinstance(label_dictionary, str):
              label_dictionary = [label_dictionary]
  
          # prepare dictionary of tags (without B- I- prefixes and without UNK)
          tag_dictionary = Dictionary(add_unk=False)
          for tag in label_dictionary:
              if tag == "<unk>" or tag == "O":
                  continue
              if len(tag) > 1 and tag[1] == "-":
                  tag = tag[2:]
                  tag_dictionary.add_item(tag)
              else:
                  tag_dictionary.add_item(tag)
  
          self._task_specific_attributes[task_name] = {
              "label_dictionary": tag_dictionary,
              "label_type": label_type,
              "multi_label": multi_label,
          }
  
      self.switch_to_task(task_name)
  
imports: import logging
  import typing
  from abc import ABC
  from collections import OrderedDict
  from pathlib import Path
  from typing import Any, Dict, List, Optional, Set, Tuple, Union
  import numpy
  import torch
  from sklearn.metrics.pairwise import cosine_similarity
  from sklearn.preprocessing import minmax_scale
  from tqdm import tqdm
  import flair
  from flair.data import Corpus, Dictionary, Sentence, Span
  from flair.datasets import DataLoader, FlairDatapointDataset
  from flair.embeddings import TokenEmbeddings, TransformerDocumentEmbeddings, TransformerWordEmbeddings
  from flair.file_utils import cached_path
  from flair.models.sequence_tagger_model import SequenceTagger
  from flair.models.text_classification_model import TextClassifier
  from flair.training_utils import store_embeddings
label_desc: Use image node_id 12 for calling the FewshotClassifier obj's underlying member method code with example usage: obj.add_and_switch_to_new_task(task_name, label_dictionary, label_type, multi_label, force_switch) without return types