code: def replace_patterns(x, replace):
      """Replace `replace` in string `x`.
  
      Parameters
      ----------
      s : str
          String on which function is applied
      replace : dict
          `key`, `value` pairs where key is a regular expression and `value` a
          string by which `key` is replaced
      """
      for from_, to in replace.items():
          x = x.replace(str(from_), str(to))
      return x
  
file_path: pytensor/pytensor/d3viz/d3viz.py
imports: import json
  import os
  import shutil
  from pytensor.d3viz.formatting import PyDotFormatter
label_desc: Use image node_id 1 for calling a global function with example usage: replace_patterns(x, replace) and returns: x