code: def extract_value(string, key):
      """Extracts from the input string the value given a key. For instance:
      input_string = "Epoch loaded: 49 - test loss: 4.71e-01, test PER: 14.21"
      print(extract_value(input_string, "test loss"))    # Output: 0.471
      print(extract_value(input_string, "test PER"))     # Output: 14.21
  
      Arguments
      ---------
      string: str
          The input string. It should be in the format mentioned above.
      key: str
          The key argument to extract.
  
      Returns
      ---------
      value: float or str
          The value corresponding to the specified key.
      """
      escaped_key = re.escape(key)
  
      # Create the regular expression pattern to match the argument and its corresponding value
      pattern = r"(?P<key>{})\s*:\s*(?P<value>[-+]?\d*\.\d+([eE][-+]?\d+)?)".format(
          escaped_key
      )
  
      # Search for the pattern in the input string
      match = re.search(pattern, string)
  
      if match:
          value = match.group("value")
          return value
      else:
          return None
  
file_path: speechbrain/tests/utils/recipe_tests.py
imports: import os
  import re
  import csv
  import sys
  import pydoc
  from time import time
  import subprocess
  from hyperpyyaml import load_hyperpyyaml
  from speechbrain.utils.data_utils import download_file
label_desc: Use image node_id 5 for calling a global function with example usage: extract_value(string, key) and returns: value, None