






from copy import deepcopy





class       __a  :







 def __init__(		self :       int							,       SCREAMING_SNAKE_CASE :       list[int] | None = None							,       SCREAMING_SNAKE_CASE :       int | None = None						):


      '''simple docstring'''






      if arr is None and size is not None:
           UpperCamelCase__      :       Union[str, Any]	    =  size
           UpperCamelCase__      :       int	    =  [0] * size
      elif arr is not None:
           self.init(SCREAMING_SNAKE_CASE						)
      else:
           raise ValueError("Either arr or size must be specified"						)







 def  __lowercase (		self :       Dict							,       SCREAMING_SNAKE_CASE :       list[int]						):


      '''simple docstring'''






      UpperCamelCase__      :       Optional[Any]	    =  len(SCREAMING_SNAKE_CASE						)
      UpperCamelCase__      :       Optional[int]	    =  deepcopy(SCREAMING_SNAKE_CASE						)
      for i in range(1							,       self.size						):
           UpperCamelCase__      :       Dict	    =  self.next_(SCREAMING_SNAKE_CASE						)
           if j < self.size:
                self.tree[j] += self.tree[i]







 def  __lowercase (		self :       Tuple						):


      '''simple docstring'''






      UpperCamelCase__      :       Tuple	    =  self.tree[:]
      for i in range(self.size - 1							,       0							,       -1						):
           UpperCamelCase__      :       str	    =  self.next_(SCREAMING_SNAKE_CASE						)
           if j < self.size:
                arr[j] -= arr[i]
      return arr







 @staticmethod
 def  __lowercase (		SCREAMING_SNAKE_CASE :       int						):


      '''simple docstring'''






      return index + (index & (-index))







 @staticmethod
 def  __lowercase (		SCREAMING_SNAKE_CASE :       int						):


      '''simple docstring'''






      return index - (index & (-index))







 def  __lowercase (		self :       Optional[int]							,       SCREAMING_SNAKE_CASE :       int							,       SCREAMING_SNAKE_CASE :       int						):


      '''simple docstring'''






      if index == 0:
           self.tree[0] += value
           return
      while index < self.size:
           self.tree[index] += value
           UpperCamelCase__      :       Dict	    =  self.next_(SCREAMING_SNAKE_CASE						)







 def  __lowercase (		self :       Optional[Any]							,       SCREAMING_SNAKE_CASE :       int							,       SCREAMING_SNAKE_CASE :       int						):


      '''simple docstring'''






      self.add(SCREAMING_SNAKE_CASE							,       value - self.get(SCREAMING_SNAKE_CASE						)						)







 def  __lowercase (		self :       Optional[int]							,       SCREAMING_SNAKE_CASE :       int						):


      '''simple docstring'''






      if right == 0:
           return 0
      UpperCamelCase__      :       Union[str, Any]	    =  self.tree[0]
      right -= 1  # make right inclusive
      while right > 0:
           result += self.tree[right]
           UpperCamelCase__      :       List[Any]	    =  self.prev(SCREAMING_SNAKE_CASE						)
      return result







 def  __lowercase (		self :       Optional[int]							,       SCREAMING_SNAKE_CASE :       int							,       SCREAMING_SNAKE_CASE :       int						):


      '''simple docstring'''






      return self.prefix(SCREAMING_SNAKE_CASE						) - self.prefix(SCREAMING_SNAKE_CASE						)







 def  __lowercase (		self :       List[str]							,       SCREAMING_SNAKE_CASE :       int						):


      '''simple docstring'''






      return self.query(SCREAMING_SNAKE_CASE							,       index + 1						)







 def  __lowercase (		self :       Tuple							,       SCREAMING_SNAKE_CASE :       int						):


      '''simple docstring'''






      value -= self.tree[0]
      if value < 0:
           return -1

      UpperCamelCase__      :       List[Any]	    =  1  # Largest power of 2 <= size
      while j * 2 < self.size:
           j *= 2

      UpperCamelCase__      :       Optional[Any]	    =  0

      while j > 0:
           if i + j < self.size and self.tree[i + j] <= value:
                value -= self.tree[i + j]
                i += j
           j //= 2
      return i


if __name__ == "__main__":
 import doctest

 doctest.testmod()







from ...configuration_utils import PretrainedConfig
from ...utils import logging


lowerCamelCase     :							Dict    =logging.get_logger(__name__)





class       __a  (   A__	):
 _lowerCAmelCase	:	Optional[int]				=			'''timm_backbone'''







 def __init__(		self :       Dict							,       SCREAMING_SNAKE_CASE :       Dict=None							,       SCREAMING_SNAKE_CASE :       List[Any]=3							,       SCREAMING_SNAKE_CASE :       List[Any]=True							,       SCREAMING_SNAKE_CASE :       Dict=True							,       SCREAMING_SNAKE_CASE :       Union[str, Any]=None							,       **SCREAMING_SNAKE_CASE :       int							,       ):


      '''simple docstring'''






      super().__init__(**SCREAMING_SNAKE_CASE						)
      UpperCamelCase__      :       Union[str, Any]	    =  backbone
      UpperCamelCase__      :       Dict	    =  num_channels
      UpperCamelCase__      :       str	    =  features_only
      UpperCamelCase__      :       Dict	    =  use_pretrained_backbone
      UpperCamelCase__      :       Tuple	    =  True
      UpperCamelCase__      :       List[Any]	    =  out_indices if out_indices is not None else (-1,)