code: class 					UpperCAmelCase_				:
  
  
  
  
      def __init__(					self  :   str   )	-> None:
        # numbermap keys are the number and its values are lists of indexes sorted
        # in ascending order
        a__     		=     {}
        # indexmap keys are an index and it's values are the number at that index
        a__     		=     {}
  
  
  
  
      def 						__lowerCamelCase (					self  :   Optional[Any]      ,      lowerCAmelCase  :   list | str | range      ,      lowerCAmelCase  :   int   )	-> list[int]:
        if isinstance(lowerCAmelCase      ,      (range, str)   ):
          a__     		=     list(lowerCAmelCase   )
        elif not isinstance(lowerCAmelCase      ,      lowerCAmelCase   ):
          raise TypeError(
              "binary_search_delete() only accepts either a list, range or str"   )
  
        a__     		=     0
        a__     		=     len(lowerCAmelCase   ) - 1
  
        while low <= high:
          a__     		=     (low + high) // 2
          if array[mid] == item:
            array.pop(lowerCAmelCase   )
            return array
          elif array[mid] < item:
            a__     		=     mid + 1
          else:
            a__     		=     mid - 1
        raise ValueError(
            "Either the item is not in the array or the array was unsorted"   )
  
  
  
  
      def 						__lowerCamelCase (					self  :   Tuple      ,      lowerCAmelCase  :   list | str | range      ,      lowerCAmelCase  :   int   )	-> list[int]:
        if isinstance(lowerCAmelCase      ,      (range, str)   ):
          a__     		=     list(lowerCAmelCase   )
        elif not isinstance(lowerCAmelCase      ,      lowerCAmelCase   ):
          raise TypeError(
              "binary_search_insert() only accepts either a list, range or str"   )
  
        a__     		=     0
        a__     		=     len(lowerCAmelCase   ) - 1
  
        while low <= high:
          a__     		=     (low + high) // 2
          if array[mid] == index:
            # If the item already exists in the array,
            # insert it after the existing item
            array.insert(mid + 1      ,      lowerCAmelCase   )
            return array
          elif array[mid] < index:
            a__     		=     mid + 1
          else:
            a__     		=     mid - 1
  
          # If the item doesn't exist in the array, insert it at the appropriate position
        array.insert(lowerCAmelCase      ,      lowerCAmelCase   )
        return array
  
  
  
  
      def 						__lowerCamelCase (					self  :   int      ,      lowerCAmelCase  :   int      ,      lowerCAmelCase  :   int   )	-> None:
        # Remove previous index
        if index in self.indexmap:
          a__     		=     self.indexmap[index]
          if len(self.numbermap[n]   ) == 1:
            del self.numbermap[n]
          else:
            a__     		=     self.binary_search_delete(self.numbermap[n]      ,      lowerCAmelCase   )
  
          # Set new index
        a__     		=     number
  
        # Number not seen before or empty so insert number value
        if number not in self.numbermap:
          a__     		=     [index]
  
        # Here we need to perform a binary search insertion in order to insert
        # The item in the correct place
        else:
          a__     		=     self.binary_search_insert(
              self.numbermap[number]      ,      lowerCAmelCase   )
  
  
  
  
      def 						__lowerCamelCase (					self  :   Optional[int]      ,      lowerCAmelCase  :   int   )	-> int:
        return self.numbermap.get(lowerCAmelCase      ,      [-1]   )[0]
  
  
  if __name__ == "__main__":
       import doctest
  
       doctest.testmod()
  
  
style_context: from unittest.mock import patch
  
  import datasets
  from datasets import Dataset
  def 				__lowercase	(						)				->Union[str, Any]:
  
    '''simple docstring'''
  
  
  
  
    a__     		=     Dataset.from_dict({"col_1": [3, 2, 0, 1]}					)
  
    with patch("tqdm.auto.tqdm"					) as mock_tqdm:
      datasets.disable_progress_bar()
      dset.map(lambda lowerCamelCase__					: {"col_2": x["col_1"] + 1}					)
      mock_tqdm.assert_not_called()
  
      mock_tqdm.reset_mock()
  
      datasets.enable_progress_bar()
      dset.map(lambda lowerCamelCase__					: {"col_2": x["col_1"] + 1}					)
      mock_tqdm.assert_called()
  
  