





from typing import TYPE_CHECKING

from ...utils import (
    OptionalDependencyNotAvailable,
    _LazyModule,
    is_tf_available,
    is_torch_available,
    is_vision_available,
)


_UpperCamelCase       :				int           =			{
    """configuration_sam""": [
        """SAM_PRETRAINED_CONFIG_ARCHIVE_MAP""",
        """SamConfig""",
        """SamMaskDecoderConfig""",
        """SamPromptEncoderConfig""",
        """SamVisionConfig""",
    ],
    """processing_sam""": ["""SamProcessor"""],
}


try:
    if not is_torch_available():
        raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
    pass
else:
    _UpperCamelCase       :				Optional[int]           =			[
        """SAM_PRETRAINED_MODEL_ARCHIVE_LIST""",
        """SamModel""",
        """SamPreTrainedModel""",
    ]
try:
    if not is_tf_available():
        raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
    pass
else:
    _UpperCamelCase       :				Optional[int]           =			[
        """TF_SAM_PRETRAINED_MODEL_ARCHIVE_LIST""",
        """TFSamModel""",
        """TFSamPreTrainedModel""",
    ]
try:
    if not is_vision_available():
        raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
    pass
else:
    _UpperCamelCase       :				Any           =			["""SamImageProcessor"""]


if TYPE_CHECKING:
    from .configuration_sam import (
        SAM_PRETRAINED_CONFIG_ARCHIVE_MAP,
        SamConfig,
        SamMaskDecoderConfig,
        SamPromptEncoderConfig,
        SamVisionConfig,
    )
    from .processing_sam import SamProcessor

    try:
        if not is_torch_available():
            raise OptionalDependencyNotAvailable()
    except OptionalDependencyNotAvailable:
        pass
    else:
        from .modeling_sam import SAM_PRETRAINED_MODEL_ARCHIVE_LIST, SamModel, SamPreTrainedModel

    try:
        if not is_tf_available():
            raise OptionalDependencyNotAvailable()
    except OptionalDependencyNotAvailable:
        pass
    else:
        from .modeling_tf_sam import TF_SAM_PRETRAINED_MODEL_ARCHIVE_LIST, TFSamModel, TFSamPreTrainedModel

    try:
        if not is_vision_available():
            raise OptionalDependencyNotAvailable()
    except OptionalDependencyNotAvailable:
        pass
    else:
        from .image_processing_sam import SamImageProcessor

else:
    import sys

    _UpperCamelCase       :				List[Any]           =			_LazyModule(__name__, globals()["""__file__"""], _import_structure, module_spec=__spec__)








import numpy as np






def 				_lowerCAmelCase			(	_a :       Optional[int]       , _a :       str      )						->      Union[str, Any]:
     lowerCAmelCase_       :							int			 =		np.array(_a      )
     lowerCAmelCase_       :							str			 =		np.array(_a      )

     lowerCAmelCase_       :							Optional[Any]			 =		abs(predict - actual      )
     lowerCAmelCase_       :							Dict			 =		difference.mean()

     return score






def 				_lowerCAmelCase			(	_a :       Union[str, Any]       , _a :       int      )						->      Tuple:
     lowerCAmelCase_       :							int			 =		np.array(_a      )
     lowerCAmelCase_       :							int			 =		np.array(_a      )

     lowerCAmelCase_       :							Union[str, Any]			 =		predict - actual
     lowerCAmelCase_       :							Tuple			 =		np.square(_a      )

     lowerCAmelCase_       :							Tuple			 =		square_diff.mean()
     return score






def 				_lowerCAmelCase			(	_a :       Optional[Any]       , _a :       Tuple      )						->      Optional[int]:
     lowerCAmelCase_       :							Optional[Any]			 =		np.array(_a      )
     lowerCAmelCase_       :							Optional[Any]			 =		np.array(_a      )

     lowerCAmelCase_       :							int			 =		predict - actual
     lowerCAmelCase_       :							Any			 =		np.square(_a      )
     lowerCAmelCase_       :							Union[str, Any]			 =		square_diff.mean()
     lowerCAmelCase_       :							Optional[Any]			 =		np.sqrt(_a      )
     return score






def 				_lowerCAmelCase			(	_a :       Optional[Any]       , _a :       Optional[Any]      )						->      List[Any]:
     lowerCAmelCase_       :							Dict			 =		np.array(_a      )
     lowerCAmelCase_       :							List[Any]			 =		np.array(_a      )

     lowerCAmelCase_       :							str			 =		np.log(predict + 1      )
     lowerCAmelCase_       :							Any			 =		np.log(actual + 1      )

     lowerCAmelCase_       :							List[str]			 =		log_predict - log_actual
     lowerCAmelCase_       :							Dict			 =		np.square(_a      )
     lowerCAmelCase_       :							Optional[Any]			 =		square_diff.mean()

     lowerCAmelCase_       :							int			 =		np.sqrt(_a      )

     return score






def 				_lowerCAmelCase			(	_a :       str       , _a :       List[Any]      )						->      int:
     lowerCAmelCase_       :							Any			 =		np.array(_a      )
     lowerCAmelCase_       :							Optional[int]			 =		np.array(_a      )

     lowerCAmelCase_       :							Optional[int]			 =		predict - actual
     lowerCAmelCase_       :							str			 =		np.sum(_a      ) / len(_a      )
     lowerCAmelCase_       :							List[str]			 =		np.sum(_a      ) / len(_a      )
     # print(numerator, denumerator)
     lowerCAmelCase_       :							int			 =		float(_a      ) / denumerator * 1_00

     return score







def 				_lowerCAmelCase			(	_a :       Any       , _a :       Union[str, Any]      )						->      str:
     return np.mean(np.array(_a      ) == np.array(_a      )      )
