





from typing import TYPE_CHECKING

from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available, is_vision_available


UpperCAmelCase_					:   Optional[Any] 							=						{
    """configuration_mobilenet_v2""": [
        """MOBILENET_V2_PRETRAINED_CONFIG_ARCHIVE_MAP""",
        """MobileNetV2Config""",
        """MobileNetV2OnnxConfig""",
    ],
}

try:
      if not is_vision_available():
            raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
      pass
else:
      UpperCAmelCase_					:   Optional[int] 							=						["""MobileNetV2FeatureExtractor"""]
      UpperCAmelCase_					:   Any 							=						["""MobileNetV2ImageProcessor"""]


try:
      if not is_torch_available():
            raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
      pass
else:
      UpperCAmelCase_					:   List[Any] 							=						[
          """MOBILENET_V2_PRETRAINED_MODEL_ARCHIVE_LIST""",
          """MobileNetV2ForImageClassification""",
          """MobileNetV2ForSemanticSegmentation""",
          """MobileNetV2Model""",
          """MobileNetV2PreTrainedModel""",
          """load_tf_weights_in_mobilenet_v2""",
      ]


if TYPE_CHECKING:
      from .configuration_mobilenet_va import (
          MOBILENET_V2_PRETRAINED_CONFIG_ARCHIVE_MAP,
          MobileNetVaConfig,
          MobileNetVaOnnxConfig,
      )

      try:
            if not is_vision_available():
                  raise OptionalDependencyNotAvailable()
      except OptionalDependencyNotAvailable:
            pass
      else:
            from .feature_extraction_mobilenet_va import MobileNetVaFeatureExtractor
            from .image_processing_mobilenet_va import MobileNetVaImageProcessor

      try:
            if not is_torch_available():
                  raise OptionalDependencyNotAvailable()
      except OptionalDependencyNotAvailable:
            pass
      else:
            from .modeling_mobilenet_va import (
                MOBILENET_V2_PRETRAINED_MODEL_ARCHIVE_LIST,
                MobileNetVaForImageClassification,
                MobileNetVaForSemanticSegmentation,
                MobileNetVaModel,
                MobileNetVaPreTrainedModel,
                load_tf_weights_in_mobilenet_va,
            )


else:
      import sys

      UpperCAmelCase_					:   Tuple 							=						_LazyModule(__name__, globals()["""__file__"""], _import_structure, module_spec=__spec__)







from collections.abc import Generator
from math import sin






def 							_lowerCAmelCase (  _a   :					bytes			)	->			bytes:
     if len(_a			) != 32:
          raise ValueError("""Input must be of length 32"""			)

     lowerCAmelCase_					:       Any    =		B""""""
     for i in [3, 2, 1, 0]:
          little_endian += string_aa[8 * i : 8 * i + 8]
     return little_endian






def 							_lowerCAmelCase (  _a   :					int			)	->			bytes:
     if i < 0:
          raise ValueError("""Input must be non-negative"""			)

     lowerCAmelCase_					:       Tuple    =		format(_a					,   """08x"""			)[-8:]
     lowerCAmelCase_					:       Any    =		B""""""
     for i in [3, 2, 1, 0]:
          little_endian_hex += hex_rep[2 * i : 2 * i + 2].encode("""utf-8"""			)
     return little_endian_hex






def 							_lowerCAmelCase (  _a   :					bytes			)	->			bytes:
     lowerCAmelCase_					:       Tuple    =		B""""""
     for char in message:
          bit_string += format(_a					,   """08b"""			).encode("""utf-8"""			)
     lowerCAmelCase_					:       Dict    =		format(len(_a			)					,   """064b"""			).encode("""utf-8"""			)

     # Pad bit_string to a multiple of 512 chars
     bit_string += b"1"
     while len(_a			) % 5_12 != 4_48:
          bit_string += b"0"
     bit_string += to_little_endian(start_len[32:]			) + to_little_endian(start_len[:32]			)

     return bit_string






def 							_lowerCAmelCase (  _a   :					bytes			)	->			Generator[list[int], None, None]:
     if len(_a			) % 5_12 != 0:
          raise ValueError("""Input must have length that's a multiple of 512"""			)

     for pos in range(0					,   len(_a			)					,   5_12			):
          lowerCAmelCase_					:       int    =		bit_string[pos : pos + 5_12]
          lowerCAmelCase_					:       Any    =		[]
          for i in range(0					,   5_12					,   32			):
               block_words.append(int(to_little_endian(block[i : i + 32]			)					,   2			)			)
          yield block_words






def 							_lowerCAmelCase (  _a   :					int			)	->			int:
     if i < 0:
          raise ValueError("""Input must be non-negative"""			)

     lowerCAmelCase_					:       List[str]    =		format(_a					,   """032b"""			)
     lowerCAmelCase_					:       Optional[int]    =		""""""
     for c in i_str:
          new_str += "1" if c == "0" else "0"
     return int(_a					,   2			)






def 							_lowerCAmelCase (  _a   :					int					,   _a   :					int			)	->			int:
     return (a + b) % 2**32






def 							_lowerCAmelCase (  _a   :					int					,   _a   :					int			)	->			int:
     if i < 0:
          raise ValueError("""Input must be non-negative"""			)
     if shift < 0:
          raise ValueError("""Shift must be non-negative"""			)
     return ((i << shift) ^ (i >> (32 - shift))) % 2**32






def 							_lowerCAmelCase (  _a   :					bytes			)	->			bytes:
     lowerCAmelCase_					:       Union[str, Any]    =		preprocess(_a			)

     lowerCAmelCase_					:       Optional[int]    =		[int(2**32 * abs(sin(i + 1			)			)			) for i in range(64			)]

     # Starting states
     lowerCAmelCase_					:       Tuple    =		0X67452301
     lowerCAmelCase_					:       Optional[int]    =		0XEFCDAB89
     lowerCAmelCase_					:       Tuple    =		0X98BADCFE
     lowerCAmelCase_					:       Tuple    =		0X10325476

     lowerCAmelCase_					:       Dict    =		[
         7,
         12,
         17,
         22,
         7,
         12,
         17,
         22,
         7,
         12,
         17,
         22,
         7,
         12,
         17,
         22,
         5,
         9,
         14,
         20,
         5,
         9,
         14,
         20,
         5,
         9,
         14,
         20,
         5,
         9,
         14,
         20,
         4,
         11,
         16,
         23,
         4,
         11,
         16,
         23,
         4,
         11,
         16,
         23,
         4,
         11,
         16,
         23,
         6,
         10,
         15,
         21,
         6,
         10,
         15,
         21,
         6,
         10,
         15,
         21,
         6,
         10,
         15,
         21,
     ]

     # Process bit string in chunks, each with 16 32-char words
     for block_words in get_block_words(_a			):
          lowerCAmelCase_					:       int    =		aa
          lowerCAmelCase_					:       Any    =		ba
          lowerCAmelCase_					:       List[str]    =		ca
          lowerCAmelCase_					:       Optional[Any]    =		da

          # Hash current chunk
          for i in range(64			):
               if i <= 15:
                    # f = (b & c) | (not_32(b) & d)     # Alternate definition for f
                    lowerCAmelCase_					:       int    =		d ^ (b & (c ^ d))
                    lowerCAmelCase_					:       List[Any]    =		i
               elif i <= 31:
                    # f = (d & b) | (not_32(d) & c)     # Alternate definition for f
                    lowerCAmelCase_					:       List[Any]    =		c ^ (d & (b ^ c))
                    lowerCAmelCase_					:       Optional[Any]    =		(5 * i + 1) % 16
               elif i <= 47:
                    lowerCAmelCase_					:       Union[str, Any]    =		b ^ c ^ d
                    lowerCAmelCase_					:       Optional[Any]    =		(3 * i + 5) % 16
               else:
                    lowerCAmelCase_					:       Any    =		c ^ (b | not_aa(_a			))
                    lowerCAmelCase_					:       List[str]    =		(7 * i) % 16
               lowerCAmelCase_					:       Tuple    =		(f + a + added_consts[i] + block_words[g]) % 2**32
               lowerCAmelCase_					:       Tuple    =		d
               lowerCAmelCase_					:       Optional[Any]    =		c
               lowerCAmelCase_					:       Dict    =		b
               lowerCAmelCase_					:       List[Any]    =		sum_aa(_a					,   left_rotate_aa(_a					,   shift_amounts[i]			)			)

          # Add hashed chunk to running total
          lowerCAmelCase_					:       Optional[int]    =		sum_aa(_a					,   _a			)
          lowerCAmelCase_					:       Optional[int]    =		sum_aa(_a					,   _a			)
          lowerCAmelCase_					:       Dict    =		sum_aa(_a					,   _a			)
          lowerCAmelCase_					:       Tuple    =		sum_aa(_a					,   _a			)

     lowerCAmelCase_					:       int    =		reformat_hex(_a			) + reformat_hex(_a			) + reformat_hex(_a			) + reformat_hex(_a			)
     return digest


if __name__ == "__main__":
      import doctest

      doctest.testmod()
