code: def subst(
      pattern: List[str], rule_symbol: str, substitute_str: str
  ) -> List[str]:
      """
      We substitute one rule symbols in a pattern according by a substitution str.
  
      example:
      pattern = "A+B=B+A"
      rule_symbol = "A"
      substitute_str = "apple"
      return: "apple+B=B+apple"
  
      :param pattern: A Pattern representing the rule.
      :param rule_symbol: One rule symbol.
      :param substitute_str: The substitution string.
      :return: The result of substitution.
      """
      assert rule_symbol in pattern
      # check which index is the same as rule_symbol
      indices = [i for i, x in enumerate(pattern) if x == rule_symbol]
  
      # form a new string with the symbol replaced
      new_string = pattern[: indices[0]] + [substitute_str]
      for i, j in zip(indices[:-1], indices[1:]):
          new_string += pattern[i + 1 : j]
          new_string += [substitute_str]
      new_string += pattern[indices[-1] + 1 :]
  
      return new_string
  
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 1 for calling a global function with example usage: subst(pattern, rule_symbol, substitute_str) and returns: new_string