code: def replace_string_in_file(
      filename: str,
      string: str,
      replace_by: str,
      encoding: str = "utf-8",
  ):
      """Read a file and replace an old value in file by a new one"""
      # Safely read the input filename using 'with'
      with open(filename, encoding=encoding) as f:
          data = f.read()
          if string not in data:
              return
  
      # Safely write the changed content, if found in the file
      with open(filename, mode="w", encoding=encoding) as f:
          data = data.replace(string, replace_by)
          f.write(data)
  
file_path: argilla/src/argilla/server/helpers.py
imports: import logging
  from typing import Any, Dict, List, Optional
label_desc: Use image node_id 6 for calling a global function with example usage: replace_string_in_file(filename, string, replace_by, encoding) without return types