code: def last_replace(s, old, new, number_of_occurrences):
      """
      Replaces last n occurrences of the old string with the new one within the string provided
  
      :param s: string to replace occurrences with
      :param old: old string
      :param new: new string
      :param number_of_occurrences: how many occurrences should be replaced
      :return: string with last n occurrences replaced
      """
      list_of_components = s.rsplit(old, number_of_occurrences)
      return new.join(list_of_components)
  
imports: from __future__ import annotations
  import sys
  from xml.etree import ElementTree
label_desc: Use image node_id 1 for calling a global function with example usage: last_replace(s, old, new, number_of_occurrences) and returns: new