code: 
  
  
  class   __lowerCamelCase :
  
  
  
  
  
  
  
         def __init__( self:   List[str]				):
  
  
  
  
  
  
              '''simple docstring'''
  
  
  
  
              __UpperCamelCase   = {}
              # indexmap keys are an index and it's values are the number at that index
              __UpperCamelCase   = {}
  
  
  
  
  
  
  
         def 		snake_case_  ( self:   Union[str, Any],A_:   list | str | range,A_:   int				):
  
  
  
  
  
  
              '''simple docstring'''
  
  
  
  
              if isinstance(_lowerCAmelCase,(range, str)				):
                   __UpperCamelCase   = list(_lowerCAmelCase				)
              elif not isinstance(_lowerCAmelCase,_lowerCAmelCase				):
                   raise TypeError(
                       'binary_search_delete() only accepts either a list, range or str'				)
  
              __UpperCamelCase   = 0
              __UpperCamelCase   = len(_lowerCAmelCase				) - 1
  
              while low <= high:
                   __UpperCamelCase   = (low + high) // 2
                   if array[mid] == item:
                        array.pop(_lowerCAmelCase				)
                        return array
                   elif array[mid] < item:
                        __UpperCamelCase   = mid + 1
                   else:
                        __UpperCamelCase   = mid - 1
              raise ValueError(
                  'Either the item is not in the array or the array was unsorted'				)
  
  
  
  
  
  
  
         def 		snake_case_  ( self:   Dict,A_:   list | str | range,A_:   int				):
  
  
  
  
  
  
              '''simple docstring'''
  
  
  
  
              if isinstance(_lowerCAmelCase,(range, str)				):
                   __UpperCamelCase   = list(_lowerCAmelCase				)
              elif not isinstance(_lowerCAmelCase,_lowerCAmelCase				):
                   raise TypeError(
                       'binary_search_insert() only accepts either a list, range or str'				)
  
              __UpperCamelCase   = 0
              __UpperCamelCase   = len(_lowerCAmelCase				) - 1
  
              while low <= high:
                   __UpperCamelCase   = (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:
                        __UpperCamelCase   = mid + 1
                   else:
                        __UpperCamelCase   = mid - 1
  
          # If the item doesn't exist in the array, insert it at the appropriate position
              array.insert(_lowerCAmelCase,_lowerCAmelCase				)
              return array
  
  
  
  
  
  
  
         def 		snake_case_  ( self:   List[str],A_:   int,A_:   int				):
  
  
  
  
  
  
              '''simple docstring'''
  
  
  
  
              if index in self.indexmap:
                   __UpperCamelCase   = self.indexmap[index]
                   if len(self.numbermap[n]				) == 1:
                        del self.numbermap[n]
                   else:
                        __UpperCamelCase   = self.binary_search_delete(self.numbermap[n],_lowerCAmelCase				)
  
          # Set new index
              __UpperCamelCase   = number
  
              # Number not seen before or empty so insert number value
              if number not in self.numbermap:
                   __UpperCamelCase   = [index]
  
              # Here we need to perform a binary search insertion in order to insert
              # The item in the correct place
              else:
                   __UpperCamelCase   = self.binary_search_insert(
                       self.numbermap[number],_lowerCAmelCase				)
  
  
  
  
  
  
  
         def 		snake_case_  ( self:   int,A_:   int				):
  
  
  
  
  
  
              '''simple docstring'''
  
  
  
  
              return self.numbermap.get(_lowerCAmelCase,[-1]				)[0]
  
  
  if __name__ == "__main__":
      import doctest
  
      doctest.testmod()
  
  
  
style_context: 
  
  
  from ..utils import DummyObject, requires_backends
  
  
  
  class   __lowerCamelCase (metaclass=_a	):
         _lowercase       							=    ["""torch""", """transformers""", """k_diffusion"""]
  
  
  
  
  
  
  
         def __init__( self:   Tuple,*A_:   Union[str, Any],**A_:   Tuple				):
  
  
  
  
  
  
              '''simple docstring'''
  
  
  
  
              requires_backends(self,['torch', 'transformers', 'k_diffusion']				)
  
  
  
  
  
  
  
         @classmethod
         def 		snake_case_  ( cls:   int,*A_:   Optional[Any],**A_:   Tuple				):
  
  
  
  
  
  
              '''simple docstring'''
  
  
  
  
              requires_backends(cls,['torch', 'transformers', 'k_diffusion']				)
  
  
  
  
  
  
  
         @classmethod
         def 		snake_case_  ( cls:   int,*A_:   Tuple,**A_:   Tuple				):
  
  
  
  
  
  
              '''simple docstring'''
  
  
  
  
              requires_backends(cls,['torch', 'transformers', 'k_diffusion']				)
  
  
  