code: def nli_resource() -> Generator[List[InputExample], None, None]:
      nli_dataset_path = "datasets/AllNLI.tsv.gz"
      if not os.path.exists(nli_dataset_path):
          util.http_get(
              "https://sbert.net/datasets/AllNLI.tsv.gz",
              nli_dataset_path,
          )
  
      label2int = {"contradiction": 0, "entailment": 1, "neutral": 2}
      nli_train_samples = []
      max_train_samples = 10000
      with gzip.open(nli_dataset_path, "rt", encoding="utf8") as f:
          reader = csv.DictReader(
              f, delimiter="\t", quoting=csv.QUOTE_NONE
          )
          for row in reader:
              if row["split"] == "train":
                  label_id = label2int[row["label"]]
                  nli_train_samples.append(
                      InputExample(
                          texts=[row["sentence1"], row["sentence2"]],
                          label=label_id,
                      )
                  )
                  if len(nli_train_samples) >= max_train_samples:
                      break
      yield nli_train_samples
  
file_path: sentence-transformers/tests/test_train_stsb.py
imports: import csv
  import gzip
  import os
  from typing import Generator, List, Tuple
  import pytest
  from torch.utils.data import DataLoader
  from sentence_transformers import SentencesDataset, SentenceTransformer, losses, util
  from sentence_transformers.evaluation import EmbeddingSimilarityEvaluator
  from sentence_transformers.readers import InputExample
label_desc: Use image node_id 2 for calling a global function with example usage: nli_resource() without return types