class_docstr: Inspired by the recent widespread use of the GLUE multi-task benchmark NLP dataset (Wang et al., 2018),
  the subsequent more difficult SuperGLUE (Wang et al., 2019),
  other previous multi-task NLP benchmarks (Conneau and Kiela, 2018; McCann et al., 2018),
  and similar initiatives in other domains (Peng et al., 2019),
  we introduce the Legal General Language Understanding Evaluation (LexGLUE) benchmark,
  a benchmark dataset to evaluate the performance of NLP methods in legal tasks.
  LexGLUE is based on seven existing legal NLP datasets, selected using criteria largely from SuperGLUE.
  Find more information on the dataset here: https://huggingface.co/datasets/lex_glue
  
  We prompt models using the following format (example for unfair_tos)
  
      <sentence>
      Unfair Contractual Term Type:
  
      Target completion:
          <sentence> (<sentence>:"Limitation of liability", "Unilateral termination", "Unilateral change",
                      "Content removal", "Contract by using", "Choice of law", "Jurisdiction", "Arbitration")
  
  Using an example from the training dataset, we have
  
  ```
  "tinder may terminate your account at any time without notice if it believes that you have violated this agreement."
  
  Unfair Contractual Term Type:
  Target completion:
      "Unilateral change"
  ```
code: def get_instances_for_subset(self, config: str) -> List[Instance]:
      task_code = TASK_CODE_MAPPING[config]
      # Load dataset
      cache_dir = str(Path(self.output_path) / "data")
      dataset: Any = load_dataset(
          self.dataset_name, config, cache_dir=cache_dir
      )
  
      if task_code in [TaskType.SLTC, TaskType.QA]:
          class_label = dataset["train"].features["label"]
          label_classes = class_label.names
      elif task_code == TaskType.MLTC:
          # construct the label classes
          label_classes = set()
          for split in self.splits_mapping.values():
              for example in dataset[split]:
                  label_classes |= set(
                      example["labels"]
                  )  # add all new labels to the set
          label_classes = sorted(
              list(map(str, label_classes))
          )  # convert everything to a string
  
      def generate_instance(example, split: str):
          # get correct labels
          if task_code in [TaskType.SLTC, TaskType.QA]:
              correct_label = class_label.int2str(
                  example["label"]
              )  # get label name for correct label
              correct_labels = (
                  correct_label
                  if isinstance(correct_label, list)
                  else [correct_label]
              )
          elif task_code == TaskType.MLTC:
              correct_labels = list(
                  map(str, example["labels"])
              )  # here we don't have any mapping to label names
  
          # construct wrong references
          wrong_references = []
          for label_name in label_classes:
              if label_name not in correct_labels:
                  wrong_reference = Reference(
                      output=Output(label_name), tags=[]
                  )  # Wrong output
                  wrong_references.append(wrong_reference)
  
          wrong_references = reduce_wrong_reference_count(
              wrong_references
          )
  
          # construct correct references and input
          if task_code in [TaskType.SLTC, TaskType.MLTC]:
              input_text = example["text"]
              if "ecthr" in config:
                  input_text = " ".join(input_text)
          elif task_code == TaskType.QA:
              endings = [
                  f"{i}: {end}"
                  for i, end in enumerate(example["endings"])
              ]
              input_text = (
                  example["context"] + " Holdings: " + " ".join(endings)
              )
  
          # construct correct references
          correct_references = [
              Reference(
                  output=Output(correct_label), tags=[CORRECT_TAG]
              )
              for correct_label in correct_labels
          ]  # for MLTC we have multiple correct ones
          return Instance(
              input=Input(input_text),
              references=wrong_references + correct_references,
              split=split,
          )
  
      def reduce_wrong_reference_count(wrong_references):
          self.random.shuffle(
              wrong_references
          )  # shuffle wrong references
          if len(wrong_references) > self.max_number_of_wrong_answers:
              # if there are too many wrong references, only take a subset
              wrong_references = wrong_references[
                  : self.max_number_of_wrong_answers
              ]
          return wrong_references
  
      def generate_instances(split: str):
          split_dataset = dataset[self.splits_mapping[split]]
          return [
              generate_instance(example, split)
              for example in split_dataset
          ]
  
      return (
          generate_instances(TRAIN_SPLIT)
          + generate_instances(VALID_SPLIT)
          + generate_instances(TEST_SPLIT)
      )
  
file_path: H2O/h2o_hf/helm/src/helm/benchmark/scenarios/lex_glue_scenario.py
imports: import random
  from pathlib import Path
  from typing import List, Any
  import datasets
  from datasets import load_dataset
  from .lextreme_scenario import TaskType
  from .scenario import Scenario, Instance, Reference, CORRECT_TAG, TRAIN_SPLIT, VALID_SPLIT, TEST_SPLIT, Input, Output
label_desc: Use image node_id 2 for calling the LexGLUEScenario obj's underlying member method code with example usage: obj.get_instances_for_subset(config) and returns: unknown, Instance, wrong_references, unknown