code: def sst_get_phrases(
      trees, sample_ratio=1.0, is_binary=False, only_sentence=False
  ):
      all_phrases = []
      for tree in trees:
          if only_sentence:
              sentence = get_sentence_by_tree(tree)
              label = int(tree.label)
              pair = (sentence, label)
              all_phrases.append(pair)
          else:
              phrases = get_phrases_by_tree(tree)
              sentence = get_sentence_by_tree(tree)
              pair = (sentence, int(tree.label))
              all_phrases.append(pair)
              all_phrases += phrases
      if sample_ratio < 1.0:
          np.random.shuffle(all_phrases)
      result_phrases = []
      for pair in all_phrases:
          if is_binary:
              phrase, label = pair
              if label <= 1:
                  pair = (phrase, 0)
              elif label >= 3:
                  pair = (phrase, 1)
              else:
                  continue
          if sample_ratio == 1.0:
              result_phrases.append(pair)
          else:
              rand_portion = np.random.random()
              if rand_portion < sample_ratio:
                  result_phrases.append(pair)
      return result_phrases
  
imports: import logging
  import os
  import pickle
  from collections import Counter
  import numpy
  import torch
  from torch.utils import data
label_desc: Use image node_id 4 for calling a global function with example usage: sst_get_phrases(trees, sample_ratio, is_binary, only_sentence) and returns: result_phrases