code: def replace_in_file(path, old, new):
      """
      Replace text occurrences in a file
      :param path: path to the file
      :param old: text to replace
      :param new: replacement
      """
      with open(path) as fp:
          content = fp.read()
  
      lpf.ensure_removed(path)
      with open(path, "w") as fp:
          fp.write(content.replace(old, new))
  
file_path: catboost/library/python/testing/yatest_common/yatest/common/path.py
imports: import errno
  import os
  import shutil
  import contextlib
  import library.python.fs
label_desc: Use image node_id 1 for calling a global function with example usage: replace_in_file(path, old, new) without return types