code: def find_left_element(sorted_data, right, comparator):
      """!
      @brief Returns the element's index at the left side from the right border with the same value as the
              last element in the range `sorted_data`.
  
      @details The element at the right is considered as target to search. `sorted_data` must
                be sorted collection. The complexity of the algorithm is `O(log(n))`. The
                algorithm is based on the binary search algorithm.
  
      @param[in] sorted_data: input data to find the element.
      @param[in] right: the index of the right element from that search is started.
      @param[in] comparator: comparison function object which returns `True` if the first argument
                  is less than the second.
  
      @return The element's index at the left side from the right border with the same value as the
               last element in the range `sorted_data`.
  
      """
      if len(sorted_data) == 0:
          raise ValueError("Input data is empty.")
  
      left = 0
      middle = (right - left) // 2
      target = sorted_data[right]
  
      while left < right:
          if comparator(sorted_data[middle], target):
              left = middle + 1
          else:
              right = middle
  
          offset = (right - left) // 2
          middle = left + offset
  
      return left
  
imports: import time
  import numpy
  from numpy import array
  from PIL import Image
  import matplotlib.pyplot
  from sys import platform
  from pyclustering.utils.metric import distance_metric, type_metric
label_desc: Use image node_id 27 for calling a global function with example usage: find_left_element(sorted_data, right, comparator) and returns: left