
'''simple docstring'''
from ctypes import c_float, sizeof
from enum import Enum
from typing import TYPE_CHECKING, Optional, Union


if TYPE_CHECKING:
  from .. import AutoFeatureExtractor, AutoProcessor, AutoTokenizer  # tests_ignore






class  UpperCAmelCase_					(						snake_case__       ):
 UpperCAmelCase_		     =    c_float





 @property
 def 							snake_case__		(     self):
     return sizeof(self.value)


def     UpperCamelCase_  (						__SCREAMING_SNAKE_CASE,		__SCREAMING_SNAKE_CASE,		__SCREAMING_SNAKE_CASE = 0							):
    """simple docstring"""






    if dimension <= 0:
        snake_case_			:     List[str]        =    fixed_dimension

    dimension -= num_token_to_add
    return dimension

def     UpperCamelCase_  (						__SCREAMING_SNAKE_CASE,		__SCREAMING_SNAKE_CASE							):
    """simple docstring"""






    return num_parameters * dtype.size


def     UpperCamelCase_  (						__SCREAMING_SNAKE_CASE							):
    """simple docstring"""






    from .. import AutoFeatureExtractor, AutoProcessor, AutoTokenizer  # tests_ignore

    try:
        return AutoProcessor.from_pretrained(__SCREAMING_SNAKE_CASE							)
    except (ValueError, OSError, KeyError):
        snake_case_      ,			snake_case_			:     List[str]        =    None, None
        try:
            snake_case_			:     Optional[Any]        =    AutoTokenizer.from_pretrained(__SCREAMING_SNAKE_CASE							)
        except (OSError, KeyError):
            pass
        try:
            snake_case_			:     Any        =    AutoFeatureExtractor.from_pretrained(__SCREAMING_SNAKE_CASE							)
        except (OSError, KeyError):
            pass

        if tokenizer is not None and feature_extractor is not None:
            raise ValueError(
                f'Couldn\'t auto-detect preprocessor for {model_name}. Found both a tokenizer and a feature extractor.'							)
        elif tokenizer is None and feature_extractor is None:
            return None
        elif tokenizer is not None:
            return tokenizer
        else:
            return feature_extractor






'''simple docstring'''
from typing import TYPE_CHECKING

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


a_           =    {
    "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:
  a_           =    [
      "SAM_PRETRAINED_MODEL_ARCHIVE_LIST",
      "SamModel",
      "SamPreTrainedModel",
  ]
try:
  if not is_tf_available():
    raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
  pass
else:
  a_           =    [
      "TF_SAM_PRETRAINED_MODEL_ARCHIVE_LIST",
      "TFSamModel",
      "TFSamPreTrainedModel",
  ]
try:
  if not is_vision_available():
    raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
  pass
else:
  a_           =    ["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

  a_           =    _LazyModule(__name__, globals()["__file__"], _import_structure, module_spec=__spec__)




