code: def main(
      corpus: Corpus,
      related_words_length: int,
      max_samples: int = -1,
      export_file: Optional[str] = None,
      *filters: Callable[[Any], Any],
  ) -> None:
      eval_factory = IncludesEvalTemplate()
  
      word_association_pairs: List[RelatedWordsPair] = []
      # Get related words for each word in the filtered corpus
      corpus = sorted(set(corpus))
      for word in corpus:
          related_words = DataMuseRelatedWords(word)
  
          # Define the processor which will perform the filteration on the related words
          # (currently the only implemented processor works on both corpus and related words)
          related_processor = WordCollectionProcessor(related_words)
  
          # Filter the related words to remove 'words' that are actually phrases
          related_processor.str_max_word_count_filter(1)
          # Filter the related words to remove words that are too long
          related_processor.sub_word_filter(word)
  
          # Apply additional filter functions
          for filter_func in filters:
              related_words = filter_func(related_words)
  
          related_words = related_processor.words.words
          if len(related_words) >= related_words_length:
              related_words = related_words[:related_words_length]
              logger.info(
                  f"Word: {word}, Related Words: {related_words}"
              )
              word_association_pairs.append(
                  RelatedWordsPair(word, ", ".join(related_words))
              )
              # generate the system message for each word association
          else:
              logger.info(
                  f"Word: {word}, Related Words: {related_words}, Skipped - Not Enough Related Words"
              )
  
      validator = EmbeddingsValidator(0.75)
      similarities: List[SimilarityTuple] = validator.validate(
          word_association_pairs
      )
  
      valid_samples: List[RelatedWordsPair] = [
          word_association_pair
          for word_association_pair, similarity, similarity_score in similarities
          if similarity
      ]
      logger.info(
          f"Total Sample: {len(word_association_pairs)} Valid Samples: {len(valid_samples)}"
      )
      for word_association_pair in valid_samples:
          system_message = generate_word_association_system_message(
              word_association_pair
          )
          user_message = generate_word_association_user_message(
              word_association_pair, corpus
          )
          eval_factory.create_sample(
              system_message, user_message, word_association_pair.word
          )
          # If the maximum number of samples have been created, break the loop
          if (
              max_samples != -1
              and len(eval_factory.samples) >= max_samples
          ):
              break
  
      if export_file is None:
          export_file = f"related_words_{related_words_length}.jsonl"
      eval_factory.export_to_jsonl(filename=export_file)
  
file_path: evals/evals/registry/data/word_association/corpus_tools/sample_generators.py
imports: import json
  import random
  from typing import Any, Callable, Dict, List, Optional
  from corpus import Corpus, NltkCorpus
  from logger_config import logger
  from processor import WordCollectionProcessor
  from related_words import DataMuseRelatedWords
  from validators import EmbeddingsValidator, RelatedWordsPair, SimilarityTuple
label_desc: Use image node_id 6 for calling a global function with example usage: main(corpus, related_words_length, max_samples, export_file) without return types