



'''simple docstring'''






import math
from typing import Optional

import numpy as np
import torch
from torch import nn

from .activations import get_activation




def 					snake_case_      (  lowerCAmelCase_ ,     lowerCAmelCase_ ,     lowerCAmelCase_ = False ,     lowerCAmelCase_ = 1 ,     lowerCAmelCase_ = 1 ,     lowerCAmelCase_ = 10000 ,     )->	Optional[Any]:





       '''simple docstring'''


       assert len(timesteps.shape	) == 1, "Timesteps should be a 1d-array"

       _UpperCAmelCase						:		Optional[int]      =				embedding_dim // 2
       _UpperCAmelCase						:		Optional[Any]      =				-math.log(lowerCAmelCase_	) * torch.arange(
           start=0 ,     end=lowerCAmelCase_ ,     dtype=torch.floataa ,     device=timesteps.device	)
       _UpperCAmelCase						:		Optional[Any]      =				exponent / (half_dim - downscale_freq_shift)

       _UpperCAmelCase						:		Tuple      =				torch.exp(lowerCAmelCase_	)
       _UpperCAmelCase						:		List[Any]      =				timesteps[:, None].float() * emb[None, :]

       # scale embeddings
       _UpperCAmelCase						:		Union[str, Any]      =				scale * emb

       # concat sine and cosine embeddings
       _UpperCAmelCase						:		int      =				torch.cat([torch.sin(lowerCAmelCase_	), torch.cos(lowerCAmelCase_	)] ,     dim=-1	)

       # flip sine and cosine embeddings
       if flip_sin_to_cos:
              _UpperCAmelCase						:		Tuple      =				torch.cat([emb[:, half_dim:], emb[:, :half_dim]] ,     dim=-1	)

       # zero pad
       if embedding_dim % 2 == 1:
              _UpperCAmelCase						:		List[str]      =				torch.nn.functional.pad(lowerCAmelCase_ ,     (0, 1, 0, 0)	)
       return emb




def 					snake_case_      (  lowerCAmelCase_ ,     lowerCAmelCase_ ,     lowerCAmelCase_=False ,     lowerCAmelCase_=0	)->	Tuple:





       '''simple docstring'''


       _UpperCAmelCase						:		Tuple      =				np.arange(lowerCAmelCase_ ,     dtype=np.floataa	)
       _UpperCAmelCase						:		int      =				np.arange(lowerCAmelCase_ ,     dtype=np.floataa	)
       _UpperCAmelCase						:		Dict      =				np.meshgrid(lowerCAmelCase_ ,     lowerCAmelCase_	)  # here w goes first
       _UpperCAmelCase						:		List[Any]      =				np.stack(lowerCAmelCase_ ,     axis=0	)

       _UpperCAmelCase						:		Optional[int]      =				grid.reshape([2, 1, grid_size, grid_size]	)
       _UpperCAmelCase						:		Union[str, Any]      =				get_ad_sincos_pos_embed_from_grid(lowerCAmelCase_ ,     lowerCAmelCase_	)
       if cls_token and extra_tokens > 0:
              _UpperCAmelCase						:		Union[str, Any]      =				np.concatenate([np.zeros([extra_tokens, embed_dim]	), pos_embed] ,     axis=0	)
       return pos_embed




def 					snake_case_      (  lowerCAmelCase_ ,     lowerCAmelCase_	)->	List[Any]:





       '''simple docstring'''


       if embed_dim % 2 != 0:
              raise ValueError("""embed_dim must be divisible by 2"""	)

       # use half of dimensions to encode grid_h
       _UpperCAmelCase						:		Dict      =				get_ad_sincos_pos_embed_from_grid(embed_dim // 2 ,     grid[0]	)  # (H*W, D/2)
       _UpperCAmelCase						:		List[str]      =				get_ad_sincos_pos_embed_from_grid(embed_dim // 2 ,     grid[1]	)  # (H*W, D/2)

       _UpperCAmelCase						:		Tuple      =				np.concatenate([emb_h, emb_w] ,     axis=1	)  # (H*W, D)
       return emb




def 					snake_case_      (  lowerCAmelCase_ ,     lowerCAmelCase_	)->	List[str]:





       '''simple docstring'''


       if embed_dim % 2 != 0:
              raise ValueError("""embed_dim must be divisible by 2"""	)

       _UpperCAmelCase						:		List[str]      =				np.arange(embed_dim // 2 ,     dtype=np.floataa	)
       omega /= embed_dim / 2.0
       _UpperCAmelCase						:		Any      =				1.0 / 10000**omega  # (D/2,)

       _UpperCAmelCase						:		str      =				pos.reshape(-1	)  # (M,)
       _UpperCAmelCase						:		Union[str, Any]      =				np.einsum("""m,d->md""" ,     lowerCAmelCase_ ,     lowerCAmelCase_	)  # (M, D/2), outer product

       _UpperCAmelCase						:		str      =				np.sin(lowerCAmelCase_	)  # (M, D/2)
       _UpperCAmelCase						:		Any      =				np.cos(lowerCAmelCase_	)  # (M, D/2)

       _UpperCAmelCase						:		int      =				np.concatenate([emb_sin, emb_cos] ,     axis=1	)  # (M, D)
       return emb



class 							lowercase (						nn.Module       ):


 """simple docstring"""


 def __init__(							self						,a_=224						,a_=224						,a_=16						,a_=3						,a_=768						,a_=False						,a_=True						,a_=True						,)	->     Optional[Any]:
        super().__init__()

        _UpperCAmelCase						:		Union[str, Any]      =				(height // patch_size) * (width // patch_size)
        _UpperCAmelCase						:		Tuple      =				flatten
        _UpperCAmelCase						:		int      =				layer_norm

        _UpperCAmelCase						:		Dict      =				nn.Convad(
            a_						,a_						,kernel_size=(patch_size, patch_size)						,stride=a_						,bias=a_							)
        if layer_norm:
               _UpperCAmelCase						:		Union[str, Any]      =				nn.LayerNorm(a_						,elementwise_affine=a_						,eps=1E-6							)
        else:
               _UpperCAmelCase						:		List[str]      =				None

        _UpperCAmelCase						:		List[str]      =				get_ad_sincos_pos_embed(a_						,int(num_patches**0.5							)							)
        self.register_buffer("""pos_embed"""						,torch.from_numpy(a_							).float().unsqueeze(0							)						,persistent=a_							)







 def _snake_case				(							self						,a_							)	->     int:
        _UpperCAmelCase						:		List[Any]      =				self.proj(a_							)
        if self.flatten:
               _UpperCAmelCase						:		List[Any]      =				latent.flatten(2							).transpose(1						,2							)  # BCHW -> BNC
        if self.layer_norm:
               _UpperCAmelCase						:		Union[str, Any]      =				self.norm(a_							)
        return latent + self.pos_embed







class 							lowercase (						nn.Module       ):


 """simple docstring"""


 def __init__(							self						,a_						,a_						,a_ = "silu"						,a_ = None						,a_ = None						,a_=None						,)	->     List[str]:
        super().__init__()

        _UpperCAmelCase						:		Optional[Any]      =				nn.Linear(a_						,a_							)

        if cond_proj_dim is not None:
               _UpperCAmelCase						:		List[Any]      =				nn.Linear(a_						,a_						,bias=a_							)
        else:
               _UpperCAmelCase						:		Optional[Any]      =				None

        _UpperCAmelCase						:		List[Any]      =				get_activation(a_							)

        if out_dim is not None:
               _UpperCAmelCase						:		List[str]      =				out_dim
        else:
               _UpperCAmelCase						:		Any      =				time_embed_dim
        _UpperCAmelCase						:		Dict      =				nn.Linear(a_						,a_							)

        if post_act_fn is None:
               _UpperCAmelCase						:		Union[str, Any]      =				None
        else:
               _UpperCAmelCase						:		Union[str, Any]      =				get_activation(a_							)







 def _snake_case				(							self						,a_						,a_=None							)	->     Tuple:
        if condition is not None:
               _UpperCAmelCase						:		Dict      =				sample + self.cond_proj(a_							)
        _UpperCAmelCase						:		str      =				self.linear_a(a_							)

        if self.act is not None:
               _UpperCAmelCase						:		Dict      =				self.act(a_							)

        _UpperCAmelCase						:		List[Any]      =				self.linear_a(a_							)

        if self.post_act is not None:
               _UpperCAmelCase						:		Tuple      =				self.post_act(a_							)
        return sample







class 							lowercase (						nn.Module       ):


 """simple docstring"""


 def __init__(							self						,a_						,a_						,a_							)	->     str:
        super().__init__()
        _UpperCAmelCase						:		Optional[int]      =				num_channels
        _UpperCAmelCase						:		int      =				flip_sin_to_cos
        _UpperCAmelCase						:		List[Any]      =				downscale_freq_shift







 def _snake_case				(							self						,a_							)	->     Optional[int]:
        _UpperCAmelCase						:		int      =				get_timestep_embedding(
            a_						,self.num_channels						,flip_sin_to_cos=self.flip_sin_to_cos						,downscale_freq_shift=self.downscale_freq_shift						,)
        return t_emb







class 							lowercase (						nn.Module       ):


 """simple docstring"""


 def __init__(							self						,a_ = 256						,a_ = 1.0						,a_=True						,a_=True						,a_=False							)	->     List[str]:
        super().__init__()
        _UpperCAmelCase						:		Tuple      =				nn.Parameter(torch.randn(a_							) * scale						,requires_grad=a_							)
        _UpperCAmelCase						:		List[Any]      =				log
        _UpperCAmelCase						:		List[Any]      =				flip_sin_to_cos

        if set_W_to_weight:
               # to delete later
               _UpperCAmelCase						:		List[Any]      =				nn.Parameter(torch.randn(a_							) * scale						,requires_grad=a_							)

               _UpperCAmelCase						:		List[str]      =				self.W







 def _snake_case				(							self						,a_							)	->     Optional[Any]:
        if self.log:
               _UpperCAmelCase						:		int      =				torch.log(a_							)

        _UpperCAmelCase						:		str      =				x[:, None] * self.weight[None, :] * 2 * np.pi

        if self.flip_sin_to_cos:
               _UpperCAmelCase						:		Dict      =				torch.cat([torch.cos(a_							), torch.sin(a_							)]						,dim=-1							)
        else:
               _UpperCAmelCase						:		Any      =				torch.cat([torch.sin(a_							), torch.cos(a_							)]						,dim=-1							)
        return out







class 							lowercase (						nn.Module       ):


 """simple docstring"""


 def __init__(							self						,a_						,a_						,a_						,a_						,)	->     Tuple:
        super().__init__()

        _UpperCAmelCase						:		str      =				height
        _UpperCAmelCase						:		Dict      =				width
        _UpperCAmelCase						:		Optional[int]      =				num_embed
        _UpperCAmelCase						:		Union[str, Any]      =				embed_dim

        _UpperCAmelCase						:		Optional[Any]      =				nn.Embedding(self.num_embed						,a_							)
        _UpperCAmelCase						:		int      =				nn.Embedding(self.height						,a_							)
        _UpperCAmelCase						:		List[Any]      =				nn.Embedding(self.width						,a_							)







 def _snake_case				(							self						,a_							)	->     Tuple:
        _UpperCAmelCase						:		Any      =				self.emb(a_							)

        _UpperCAmelCase						:		str      =				self.height_emb(torch.arange(self.height						,device=index.device							).view(1						,self.height							)							)

        # 1 x H x D -> 1 x H x 1 x D
        _UpperCAmelCase						:		int      =				height_emb.unsqueeze(2							)

        _UpperCAmelCase						:		Union[str, Any]      =				self.width_emb(torch.arange(self.width						,device=index.device							).view(1						,self.width							)							)

        # 1 x W x D -> 1 x 1 x W x D
        _UpperCAmelCase						:		Tuple      =				width_emb.unsqueeze(1							)

        _UpperCAmelCase						:		Any      =				height_emb + width_emb

        # 1 x H x W x D -> 1 x L xD
        _UpperCAmelCase						:		Dict      =				pos_emb.view(1						,self.height * self.width						,-1							)

        _UpperCAmelCase						:		int      =				emb + pos_emb[:, : emb.shape[1], :]

        return emb







class 							lowercase (						nn.Module       ):


 """simple docstring"""


 def __init__(							self						,a_						,a_						,a_							)	->     Any:
        super().__init__()
        _UpperCAmelCase						:		List[Any]      =				dropout_prob > 0
        _UpperCAmelCase						:		Optional[Any]      =				nn.Embedding(num_classes + use_cfg_embedding						,a_							)
        _UpperCAmelCase						:		Dict      =				num_classes
        _UpperCAmelCase						:		Tuple      =				dropout_prob







 def _snake_case				(							self						,a_						,a_=None							)	->     Optional[Any]:
        if force_drop_ids is None:
               _UpperCAmelCase						:		Union[str, Any]      =				torch.rand(labels.shape[0]						,device=labels.device							) < self.dropout_prob
        else:
               _UpperCAmelCase						:		Tuple      =				torch.tensor(force_drop_ids == 1							)
        _UpperCAmelCase						:		Dict      =				torch.where(a_						,self.num_classes						,a_							)
        return labels







 def _snake_case				(							self						,a_						,a_=None							)	->     Union[str, Any]:
        _UpperCAmelCase						:		int      =				self.dropout_prob > 0
        if (self.training and use_dropout) or (force_drop_ids is not None):
               _UpperCAmelCase						:		str      =				self.token_drop(a_						,a_							)
        _UpperCAmelCase						:		List[Any]      =				self.embedding_table(a_							)
        return embeddings







class 							lowercase (						nn.Module       ):


 """simple docstring"""


 def __init__(							self						,a_ = 1_024						,a_ = 768						,a_ = 768						,a_ = 10						,)	->     int:
        super().__init__()

        _UpperCAmelCase						:		Optional[int]      =				num_image_text_embeds
        _UpperCAmelCase						:		Optional[int]      =				nn.Linear(a_						,self.num_image_text_embeds * cross_attention_dim							)
        _UpperCAmelCase						:		Dict      =				nn.Linear(a_						,a_							)







 def _snake_case				(							self						,a_						,a_							)	->     Union[str, Any]:
        _UpperCAmelCase						:		List[Any]      =				text_embeds.shape[0]

        # image
        _UpperCAmelCase						:		Tuple      =				self.image_embeds(a_							)
        _UpperCAmelCase						:		Dict      =				image_text_embeds.reshape(a_						,self.num_image_text_embeds						,-1							)

        # text
        _UpperCAmelCase						:		Tuple      =				self.text_proj(a_							)

        return torch.cat([image_text_embeds, text_embeds]						,dim=1							)







class 							lowercase (						nn.Module       ):


 """simple docstring"""


 def __init__(							self						,a_ = 768						,a_ = 768						,a_ = 32						,)	->     int:
        super().__init__()

        _UpperCAmelCase						:		Optional[int]      =				num_image_text_embeds
        _UpperCAmelCase						:		Dict      =				nn.Linear(a_						,self.num_image_text_embeds * cross_attention_dim							)
        _UpperCAmelCase						:		Tuple      =				nn.LayerNorm(a_							)







 def _snake_case				(							self						,a_							)	->     int:
        _UpperCAmelCase						:		Dict      =				image_embeds.shape[0]

        # image
        _UpperCAmelCase						:		List[Any]      =				self.image_embeds(a_							)
        _UpperCAmelCase						:		int      =				image_embeds.reshape(a_						,self.num_image_text_embeds						,-1							)
        _UpperCAmelCase						:		Any      =				self.norm(a_							)
        return image_embeds







class 							lowercase (						nn.Module       ):


 """simple docstring"""


 def __init__(							self						,a_						,a_						,a_=0.1							)	->     Union[str, Any]:
        super().__init__()

        _UpperCAmelCase						:		Any      =				Timesteps(num_channels=256						,flip_sin_to_cos=a_						,downscale_freq_shift=1							)
        _UpperCAmelCase						:		Any      =				TimestepEmbedding(in_channels=256						,time_embed_dim=a_							)
        _UpperCAmelCase						:		int      =				LabelEmbedding(a_						,a_						,a_							)







 def _snake_case				(							self						,a_						,a_						,a_=None							)	->     Optional[int]:
        _UpperCAmelCase						:		Tuple      =				self.time_proj(a_							)
        _UpperCAmelCase						:		List[str]      =				self.timestep_embedder(timesteps_proj.to(dtype=a_							)							)  # (N, D)

        _UpperCAmelCase						:		str      =				self.class_embedder(a_							)  # (N, D)

        _UpperCAmelCase						:		str      =				timesteps_emb + class_labels  # (N, D)

        return conditioning







class 							lowercase (						nn.Module       ):


 """simple docstring"""


 def __init__(							self						,a_						,a_						,a_ = 64							)	->     Optional[Any]:
        super().__init__()
        _UpperCAmelCase						:		str      =				nn.LayerNorm(a_							)
        _UpperCAmelCase						:		List[Any]      =				AttentionPooling(a_						,a_							)
        _UpperCAmelCase						:		Any      =				nn.Linear(a_						,a_							)
        _UpperCAmelCase						:		List[Any]      =				nn.LayerNorm(a_							)







 def _snake_case				(							self						,a_							)	->     str:
        _UpperCAmelCase						:		Optional[Any]      =				self.norma(a_							)
        _UpperCAmelCase						:		Dict      =				self.pool(a_							)
        _UpperCAmelCase						:		Optional[Any]      =				self.proj(a_							)
        _UpperCAmelCase						:		str      =				self.norma(a_							)
        return hidden_states







class 							lowercase (						nn.Module       ):


 """simple docstring"""


 def __init__(							self						,a_ = 768						,a_ = 768						,a_ = 1_536							)	->     Any:
        super().__init__()
        _UpperCAmelCase						:		int      =				nn.Linear(a_						,a_							)
        _UpperCAmelCase						:		Any      =				nn.LayerNorm(a_							)
        _UpperCAmelCase						:		Optional[Any]      =				nn.Linear(a_						,a_							)







 def _snake_case				(							self						,a_						,a_							)	->     Optional[int]:
        # text
        _UpperCAmelCase						:		List[Any]      =				self.text_proj(a_							)
        _UpperCAmelCase						:		Optional[Any]      =				self.text_norm(a_							)

        # image
        _UpperCAmelCase						:		int      =				self.image_proj(a_							)

        return time_image_embeds + time_text_embeds







class 							lowercase (						nn.Module       ):


 """simple docstring"""


 def __init__(							self						,a_ = 768						,a_ = 1_536							)	->     int:
        super().__init__()
        _UpperCAmelCase						:		Optional[int]      =				nn.Linear(a_						,a_							)
        _UpperCAmelCase						:		str      =				nn.LayerNorm(a_							)







 def _snake_case				(							self						,a_							)	->     int:
        # image
        _UpperCAmelCase						:		Optional[int]      =				self.image_proj(a_							)
        _UpperCAmelCase						:		Tuple      =				self.image_norm(a_							)
        return time_image_embeds







class 							lowercase (						nn.Module       ):


 """simple docstring"""


 def __init__(							self						,a_ = 768						,a_ = 1_536							)	->     int:
        super().__init__()
        _UpperCAmelCase						:		List[Any]      =				nn.Linear(a_						,a_							)
        _UpperCAmelCase						:		int      =				nn.LayerNorm(a_							)
        _UpperCAmelCase						:		Union[str, Any]      =				nn.Sequential(
            nn.Convad(3						,16						,3						,padding=1							)						,nn.SiLU()						,nn.Convad(16						,16						,3						,padding=1							)						,nn.SiLU()						,nn.Convad(16						,32						,3						,padding=1						,stride=2							)						,nn.SiLU()						,nn.Convad(32						,32						,3						,padding=1							)						,nn.SiLU()						,nn.Convad(32						,96						,3						,padding=1						,stride=2							)						,nn.SiLU()						,nn.Convad(96						,96						,3						,padding=1							)						,nn.SiLU()						,nn.Convad(96						,256						,3						,padding=1						,stride=2							)						,nn.SiLU()						,nn.Convad(256						,4						,3						,padding=1							)						,)







 def _snake_case				(							self						,a_						,a_							)	->     Union[str, Any]:
        # image
        _UpperCAmelCase						:		Union[str, Any]      =				self.image_proj(a_							)
        _UpperCAmelCase						:		Optional[Any]      =				self.image_norm(a_							)
        _UpperCAmelCase						:		List[Any]      =				self.input_hint_block(a_							)
        return time_image_embeds, hint







class 							lowercase (						nn.Module       ):


 """simple docstring"""


 def __init__(							self						,a_						,a_						,a_=None							)	->     Optional[Any]:
        super().__init__()
        _UpperCAmelCase						:		Union[str, Any]      =				dtype
        _UpperCAmelCase						:		Optional[int]      =				nn.Parameter(torch.randn(1						,a_							) / embed_dim**0.5							)
        _UpperCAmelCase						:		Union[str, Any]      =				nn.Linear(a_						,a_						,dtype=self.dtype							)
        _UpperCAmelCase						:		Tuple      =				nn.Linear(a_						,a_						,dtype=self.dtype							)
        _UpperCAmelCase						:		List[str]      =				nn.Linear(a_						,a_						,dtype=self.dtype							)
        _UpperCAmelCase						:		Union[str, Any]      =				num_heads
        _UpperCAmelCase						:		Any      =				embed_dim // self.num_heads







 def _snake_case				(							self						,a_							)	->     Optional[int]:
        _UpperCAmelCase  ,_UpperCAmelCase  ,_UpperCAmelCase						:		Tuple      =				x.size()

        def shape(a_							):
               # (bs, length, width) --> (bs, length, n_heads, dim_per_head)
               _UpperCAmelCase						:		Any      =				x.view(a_						,-1						,self.num_heads						,self.dim_per_head							)
               # (bs, length, n_heads, dim_per_head) --> (bs, n_heads, length, dim_per_head)
               _UpperCAmelCase						:		str      =				x.transpose(1						,2							)
               # (bs, n_heads, length, dim_per_head) --> (bs*n_heads, length, dim_per_head)
               _UpperCAmelCase						:		int      =				x.reshape(bs * self.num_heads						,-1						,self.dim_per_head							)
               # (bs*n_heads, length, dim_per_head) --> (bs*n_heads, dim_per_head, length)
               _UpperCAmelCase						:		List[Any]      =				x.transpose(1						,2							)
               return x

        _UpperCAmelCase						:		int      =				x.mean(dim=1						,keepdim=a_							) + self.positional_embedding.to(x.dtype							)
        _UpperCAmelCase						:		Optional[int]      =				torch.cat([class_token, x]						,dim=1							)  # (bs, length+1, width)

        # (bs*n_heads, class_token_length, dim_per_head)
        _UpperCAmelCase						:		Dict      =				shape(self.q_proj(a_							)							)
        # (bs*n_heads, length+class_token_length, dim_per_head)
        _UpperCAmelCase						:		Optional[Any]      =				shape(self.k_proj(a_							)							)
        _UpperCAmelCase						:		Optional[Any]      =				shape(self.v_proj(a_							)							)

        # (bs*n_heads, class_token_length, length+class_token_length):
        _UpperCAmelCase						:		Union[str, Any]      =				1 / math.sqrt(math.sqrt(self.dim_per_head							)							)
        _UpperCAmelCase						:		Dict      =				torch.einsum("""bct,bcs->bts"""						,q * scale						,k * scale							)  # More stable with f16 than dividing afterwards
        _UpperCAmelCase						:		Union[str, Any]      =				torch.softmax(weight.float()						,dim=-1							).type(weight.dtype							)

        # (bs*n_heads, dim_per_head, class_token_length)
        _UpperCAmelCase						:		Tuple      =				torch.einsum("""bts,bcs->bct"""						,a_						,a_							)

        # (bs, length+1, width)
        _UpperCAmelCase						:		Any      =				a.reshape(a_						,-1						,1							).transpose(1						,2							)

        return a[:, 0, :]  # cls_token








'''simple docstring'''






from typing import TYPE_CHECKING

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


A_							:				Union[str, Any]						=			{
    """configuration_segformer""": ["""SEGFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP""", """SegformerConfig""", """SegformerOnnxConfig"""]
}

try:
   if not is_vision_available():
      raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
   pass
else:
   A_							:				Tuple						=			["""SegformerFeatureExtractor"""]
   A_							:				Tuple						=			["""SegformerImageProcessor"""]

try:
   if not is_torch_available():
      raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
   pass
else:
   A_							:				Dict						=			[
       """SEGFORMER_PRETRAINED_MODEL_ARCHIVE_LIST""",
       """SegformerDecodeHead""",
       """SegformerForImageClassification""",
       """SegformerForSemanticSegmentation""",
       """SegformerLayer""",
       """SegformerModel""",
       """SegformerPreTrainedModel""",
   ]

try:
   if not is_tf_available():
      raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
   pass
else:
   A_							:				List[str]						=			[
       """TF_SEGFORMER_PRETRAINED_MODEL_ARCHIVE_LIST""",
       """TFSegformerDecodeHead""",
       """TFSegformerForImageClassification""",
       """TFSegformerForSemanticSegmentation""",
       """TFSegformerModel""",
       """TFSegformerPreTrainedModel""",
   ]


if TYPE_CHECKING:
   from .configuration_segformer import SEGFORMER_PRETRAINED_CONFIG_ARCHIVE_MAP, SegformerConfig, SegformerOnnxConfig

   try:
      if not is_vision_available():
         raise OptionalDependencyNotAvailable()
   except OptionalDependencyNotAvailable:
      pass
   else:
      from .feature_extraction_segformer import SegformerFeatureExtractor
      from .image_processing_segformer import SegformerImageProcessor

   try:
      if not is_torch_available():
         raise OptionalDependencyNotAvailable()
   except OptionalDependencyNotAvailable:
      pass
   else:
      from .modeling_segformer import (
          SEGFORMER_PRETRAINED_MODEL_ARCHIVE_LIST,
          SegformerDecodeHead,
          SegformerForImageClassification,
          SegformerForSemanticSegmentation,
          SegformerLayer,
          SegformerModel,
          SegformerPreTrainedModel,
      )
   try:
      if not is_tf_available():
         raise OptionalDependencyNotAvailable()
   except OptionalDependencyNotAvailable:
      pass
   else:
      from .modeling_tf_segformer import (
          TF_SEGFORMER_PRETRAINED_MODEL_ARCHIVE_LIST,
          TFSegformerDecodeHead,
          TFSegformerForImageClassification,
          TFSegformerForSemanticSegmentation,
          TFSegformerModel,
          TFSegformerPreTrainedModel,
      )

else:
   import sys

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



