code: def pattern_subst(
      pattern: List[str],
      rule_symbols: List[str],
      substitute_dict: Dict[str, str],
  ) -> List[str]:
      """
      We substitute the rule symbols in a pattern according to a substitution dictionary.
  
      example:
      pattern = "A+B=B+A"
      rule_symbols = ["A", "B"]
      substitute_dict = {"A":"apple", "B":"peach"}
      return: "apple+peach=peach+apple"
  
      :param pattern: A Pattern representing the rule.
      :param rule_symbols: The set of rule symbols.
      :param substitute_dict: The substitution dictionary.
      :return: The result of substitution.
      """
  
      out = pattern
      # we iteratively replace each rule symbol with its subsitution string
      for symbol in rule_symbols:
          out = subst(out, symbol, substitute_dict[symbol])
      return out
  
file_path: H2O/h2o_hf/helm/src/helm/benchmark/scenarios/synthetic_reasoning_scenario.py
imports: import numpy
  from typing import List, Dict, Tuple
  from .scenario import Scenario, Instance, Reference, TRAIN_SPLIT, VALID_SPLIT, TEST_SPLIT, CORRECT_TAG, Input, Output
label_desc: Use image node_id 2 for calling a global function with example usage: pattern_subst(pattern, rule_symbols, substitute_dict) and returns: out