


from typing import List, Optional, Tuple, Union

import torch
from torch import nn
from torch.nn import CrossEntropyLoss

from ... import AutoBackbone
from ...modeling_outputs import SemanticSegmenterOutput
from ...modeling_utils import PreTrainedModel
from ...utils import add_start_docstrings, add_start_docstrings_to_model_forward, replace_return_docstrings
from ...utils.backbone_utils import BackboneMixin
from .configuration_upernet import UperNetConfig


__lowerCamelCase        =     [
    '''openmmlab/upernet-convnext-tiny''',
    # See all UperNet models at https://huggingface.co/models?filter=upernet
]

# General docstring
__lowerCamelCase        =     '''UperNetConfig'''


class   a__	(						nn.Module    ):

       def __init__(   self      :     Any      ,							lowerCamelCase_      :     int      ,							lowerCamelCase_      :     int      ,							lowerCamelCase_      :     Union[int, Tuple[int, int]]      ,							lowerCamelCase_      :     Union[int, Tuple[int, int], str] = 0      ,							lowerCamelCase_      :     bool = False      ,							lowerCamelCase_      :     Union[int, Tuple[int, int]] = 1      ,							):
            super().__init__()
            a_    :     str										=    nn.Convad(
                in_channels=lowerCamelCase_      ,							out_channels=lowerCamelCase_      ,							kernel_size=lowerCamelCase_      ,							padding=lowerCamelCase_      ,							bias=lowerCamelCase_      ,							dilation=lowerCamelCase_      ,							)
            a_    :     Dict										=    nn.BatchNormad(lowerCamelCase_    )
            a_    :     Union[str, Any]										=    nn.ReLU()

       def 						UpperCAmelCase(   self      :     str      ,							lowerCamelCase_      :     torch.Tensor    ):
            a_    :     Tuple										=    self.conv(lowerCamelCase_    )
            a_    :     int										=    self.batch_norm(lowerCamelCase_    )
            a_    :     Optional[int]										=    self.activation(lowerCamelCase_    )

            return output


class   a__	(						nn.Module    ):

       def __init__(   self      :     List[str]      ,							lowerCamelCase_      :     int      ,							lowerCamelCase_      :     int      ,							lowerCamelCase_      :     int    ):
            super().__init__()
            a_    :     Union[str, Any]										=    [
                nn.AdaptiveAvgPoolad(lowerCamelCase_    ),
                UperNetConvModule(lowerCamelCase_      ,							lowerCamelCase_      ,							kernel_size=1    ),
            ]
            for i, layer in enumerate(self.layers    ):
                 self.add_module(str(lowerCamelCase_    )      ,							lowerCamelCase_    )

       def 						UpperCAmelCase(   self      :     List[Any]      ,							lowerCamelCase_      :     torch.Tensor    ):
            a_    :     Optional[int]										=    input
            for layer in self.layers:
                 a_    :     Dict										=    layer(lowerCamelCase_    )
            return hidden_state


class   a__	(						nn.Module    ):

       def __init__(   self      :     Union[str, Any]      ,							lowerCamelCase_      :     Tuple[int, ...]      ,							lowerCamelCase_      :     int      ,							lowerCamelCase_      :     int      ,							lowerCamelCase_      :     bool    ):
            super().__init__()
            a_    :     Optional[int]										=    pool_scales
            a_    :     List[Any]										=    align_corners
            a_    :     Union[str, Any]										=    in_channels
            a_    :     List[str]										=    channels
            a_    :     Optional[int]										=    []
            for i, pool_scale in enumerate(lowerCamelCase_    ):
                 a_    :     Optional[int]										=    UperNetPyramidPoolingBlock(pool_scale=lowerCamelCase_      ,							in_channels=lowerCamelCase_      ,							channels=lowerCamelCase_    )
                 self.blocks.append(lowerCamelCase_    )
                 self.add_module(str(lowerCamelCase_    )      ,							lowerCamelCase_    )

       def 						UpperCAmelCase(   self      :     List[str]      ,							lowerCamelCase_      :     torch.Tensor    ):
            a_    :     List[str]										=    []
            for ppm in self.blocks:
                 a_    :     Any										=    ppm(lowerCamelCase_    )
                 a_    :     str										=    nn.functional.interpolate(
                     lowerCamelCase_      ,							size=x.size()[2:]      ,							mode="""bilinear"""      ,							align_corners=self.align_corners    )
                 ppm_outs.append(lowerCamelCase_    )
            return ppm_outs


class   a__	(						nn.Module    ):

       def __init__(   self      :     Any      ,							lowerCamelCase_      :     Union[str, Any]      ,							lowerCamelCase_      :     int    ):
            super().__init__()

            a_    :     Tuple										=    config
            a_    :     int										=    config.pool_scales  # e.g. (1, 2, 3, 6)
            a_    :     str										=    in_channels
            a_    :     str										=    config.hidden_size
            a_    :     int										=    False
            a_    :     int										=    nn.Convad(self.channels      ,							config.num_labels      ,							kernel_size=1    )

            # PSP Module
            a_    :     Optional[int]										=    UperNetPyramidPoolingModule(
                self.pool_scales      ,							self.in_channels[-1]      ,							self.channels      ,							align_corners=self.align_corners      ,							)
            a_    :     int										=    UperNetConvModule(
                self.in_channels[-1] + len(self.pool_scales    ) * self.channels      ,							self.channels      ,							kernel_size=3      ,							padding=1      ,							)
            # FPN Module
            a_    :     List[Any]										=    nn.ModuleList()
            a_    :     Optional[int]										=    nn.ModuleList()
            for in_channels in self.in_channels[:-1]:  # skip the top layer
                 a_    :     List[str]										=    UperNetConvModule(lowerCamelCase_      ,							self.channels      ,							kernel_size=1    )
                 a_    :     Union[str, Any]										=    UperNetConvModule(self.channels      ,							self.channels      ,							kernel_size=3      ,							padding=1    )
                 self.lateral_convs.append(lowerCamelCase_    )
                 self.fpn_convs.append(lowerCamelCase_    )

            a_    :     str										=    UperNetConvModule(
                len(self.in_channels    ) * self.channels      ,							self.channels      ,							kernel_size=3      ,							padding=1      ,							)

       def 						UpperCAmelCase(   self      :     str    ):
            self.apply(self._init_weights    )

       def 						UpperCAmelCase(   self      :     Any      ,							lowerCamelCase_      :     Union[str, Any]    ):
            if isinstance(lowerCamelCase_      ,							nn.Convad    ):
                 module.weight.data.normal_(mean=0.0      ,							std=self.config.initializer_range    )
                 if module.bias is not None:
                      module.bias.data.zero_()

       def 						UpperCAmelCase(   self      :     Tuple      ,							lowerCamelCase_      :     Optional[int]    ):
            a_    :     Optional[int]										=    inputs[-1]
            a_    :     List[str]										=    [x]
            psp_outs.extend(self.psp_modules(lowerCamelCase_    )    )
            a_    :     int										=    torch.cat(lowerCamelCase_      ,							dim=1    )
            a_    :     Tuple										=    self.bottleneck(lowerCamelCase_    )

            return output

       def 						UpperCAmelCase(   self      :     List[str]      ,							lowerCamelCase_      :     torch.Tensor    ):
            # build laterals
            a_    :     List[Any]										=    [lateral_conv(encoder_hidden_states[i]    ) for i, lateral_conv in enumerate(self.lateral_convs    )]

            laterals.append(self.psp_forward(lowerCamelCase_    )    )

            # build top-down path
            a_    :     Tuple										=    len(lowerCamelCase_    )
            for i in range(used_backbone_levels - 1      ,							0      ,							-1    ):
                 a_    :     List[Any]										=    laterals[i - 1].shape[2:]
                 a_    :     int										=    laterals[i - 1] + nn.functional.interpolate(
                     laterals[i]      ,							size=lowerCamelCase_      ,							mode="""bilinear"""      ,							align_corners=self.align_corners    )

            # build outputs
            a_    :     int										=    [self.fpn_convs[i](laterals[i]    ) for i in range(used_backbone_levels - 1    )]
            # append psp feature
            fpn_outs.append(laterals[-1]    )

            for i in range(used_backbone_levels - 1      ,							0      ,							-1    ):
                 a_    :     Union[str, Any]										=    nn.functional.interpolate(
                     fpn_outs[i]      ,							size=fpn_outs[0].shape[2:]      ,							mode="""bilinear"""      ,							align_corners=self.align_corners    )
            a_    :     Optional[Any]										=    torch.cat(lowerCamelCase_      ,							dim=1    )
            a_    :     Tuple										=    self.fpn_bottleneck(lowerCamelCase_    )
            a_    :     str										=    self.classifier(lowerCamelCase_    )

            return output


class   a__	(						nn.Module    ):

       def __init__(   self      :     Union[str, Any]      ,							lowerCamelCase_      :     Optional[Any]      ,							lowerCamelCase_      :     int = 2      ,							lowerCamelCase_      :     int = 3      ,							lowerCamelCase_      :     Union[int, Tuple[int, int]] = 1    ):
            super().__init__()

            a_    :     Union[str, Any]										=    config
            a_    :     str										=    config.auxiliary_in_channels
            a_    :     List[str]										=    config.auxiliary_channels
            a_    :     List[Any]										=    config.auxiliary_num_convs
            a_    :     Optional[Any]										=    config.auxiliary_concat_input
            a_    :     str										=    in_index

            a_    :     str										=    (kernel_size // 2) * dilation
            a_    :     Union[str, Any]										=    []
            convs.append(
                UperNetConvModule(
                    self.in_channels      ,							self.channels      ,							kernel_size=lowerCamelCase_      ,							padding=lowerCamelCase_      ,							dilation=lowerCamelCase_    )    )
            for i in range(self.num_convs - 1    ):
                 convs.append(
                     UperNetConvModule(
                         self.channels      ,							self.channels      ,							kernel_size=lowerCamelCase_      ,							padding=lowerCamelCase_      ,							dilation=lowerCamelCase_    )    )
            if self.num_convs == 0:
                 a_    :     Dict										=    nn.Identity()
            else:
                 a_    :     Optional[Any]										=    nn.Sequential(*lowerCamelCase_    )
            if self.concat_input:
                 a_    :     List[str]										=    UperNetConvModule(
                     self.in_channels + self.channels      ,							self.channels      ,							kernel_size=lowerCamelCase_      ,							padding=kernel_size // 2    )

            a_    :     str										=    nn.Convad(self.channels      ,							config.num_labels      ,							kernel_size=1    )

       def 						UpperCAmelCase(   self      :     Optional[int]    ):
            self.apply(self._init_weights    )

       def 						UpperCAmelCase(   self      :     List[str]      ,							lowerCamelCase_      :     Dict    ):
            if isinstance(lowerCamelCase_      ,							nn.Convad    ):
                 module.weight.data.normal_(mean=0.0      ,							std=self.config.initializer_range    )
                 if module.bias is not None:
                      module.bias.data.zero_()

       def 						UpperCAmelCase(   self      :     Any      ,							lowerCamelCase_      :     torch.Tensor    ):
            # just take the relevant feature maps
            a_    :     List[Any]										=    encoder_hidden_states[self.in_index]
            a_    :     Any										=    self.convs(lowerCamelCase_    )
            if self.concat_input:
                 a_    :     Optional[Any]										=    self.conv_cat(torch.cat([hidden_states, output]      ,							dim=1    )    )
            a_    :     Union[str, Any]										=    self.classifier(lowerCamelCase_    )
            return output


class   a__	(						lowerCAmelCase_    ):
       lowerCamelCase__:     Tuple							    =     UperNetConfig
       lowerCamelCase__:     Tuple							    =     """pixel_values"""
       lowerCamelCase__:     Optional[Any]							    =     True

       def 						UpperCAmelCase(   self      :     Optional[int]      ,							lowerCamelCase_      :     str    ):
            if isinstance(lowerCamelCase_      ,							lowerCamelCase_    ):
                 module.backbone.init_weights()
                 module.decode_head.init_weights()
                 module.auxiliary_head.init_weights()

       def 						UpperCAmelCase(   self      :     List[str]    ):
            self.backbone.init_weights()
            self.decode_head.init_weights()
            self.auxiliary_head.init_weights()

       def 						UpperCAmelCase(   self      :     Optional[Any]      ,							lowerCamelCase_      :     List[Any]      ,							lowerCamelCase_      :     str=False    ):
            if isinstance(lowerCamelCase_      ,							lowerCamelCase_    ):
                 a_    :     List[Any]										=    value

__lowerCamelCase        =     R'''
    Parameters:
    This model is a PyTorch [torch.nn.Module](https://pytorch.org/docs/stable/nn.html#torch.nn.Module) sub-class. Use
    it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage and
    behavior.
        config ([`UperNetConfig`]): Model configuration class with all the parameters of the model.
            Initializing with a config file does not load the weights associated with the model, only the
            configuration. Check out the [`~PreTrainedModel.from_pretrained`] method to load the model weights.
'''

__lowerCamelCase        =     R'''
    Args:
        pixel_values (`torch.FloatTensor` of shape `(batch_size, num_channels, height, width)`):
            Pixel values. Padding will be ignored by default should you provide it. Pixel values can be obtained using
            [`AutoImageProcessor`]. See [`SegformerImageProcessor.__call__`] for details.
        output_attentions (`bool`, *optional*):
            Whether or not to return the attentions tensors of all attention layers in case the backbone has them. See
            `attentions` under returned tensors for more detail.
        output_hidden_states (`bool`, *optional*):
            Whether or not to return the hidden states of all layers of the backbone. See `hidden_states` under
            returned tensors for more detail.
        return_dict (`bool`, *optional*):
            Whether or not to return a [`~utils.ModelOutput`] instead of a plain tuple.
'''


@add_start_docstrings(
    """UperNet framework leveraging any vision backbone e.g. for ADE20k, CityScapes."""						,       lowerCAmelCase_						,       )
class   a__	(						lowerCAmelCase_    ):

       def __init__(   self      :     Optional[int]      ,							lowerCamelCase_      :     Optional[Any]    ):
            super().__init__(lowerCamelCase_    )

            a_    :     str										=    AutoBackbone.from_config(config.backbone_config    )

            # Semantic segmentation head(s)
            a_    :     List[Any]										=    UperNetHead(lowerCamelCase_      ,							in_channels=self.backbone.channels    )
            a_    :     List[str]										=    UperNetFCNHead(lowerCamelCase_    ) if config.use_auxiliary_head else None

            # Initialize weights and apply final processing
            self.post_init()

       @add_start_docstrings_to_model_forward(UPERNET_INPUTS_DOCSTRING.format("""batch_size, sequence_length"""    )    )
       @replace_return_docstrings(output_type=lowerCamelCase_      ,							config_class=_CONFIG_FOR_DOC    )
       def 						UpperCAmelCase(   self      :     Union[str, Any]      ,							lowerCamelCase_      :     Optional[torch.Tensor] = None      ,							lowerCamelCase_      :     Optional[bool] = None      ,							lowerCamelCase_      :     Optional[bool] = None      ,							lowerCamelCase_      :     Optional[torch.Tensor] = None      ,							lowerCamelCase_      :     Optional[bool] = None      ,							):
            a_    :     List[str]										=    return_dict if return_dict is not None else self.config.use_return_dict
            a_    :     Any										=    (
                output_hidden_states if output_hidden_states is not None else self.config.output_hidden_states
            )
            a_    :     Tuple										=    output_attentions if output_attentions is not None else self.config.output_attentions

            a_    :     List[Any]										=    self.backbone.forward_with_filtered_kwargs(
                lowerCamelCase_      ,							output_hidden_states=lowerCamelCase_      ,							output_attentions=lowerCamelCase_    )
            a_    :     str										=    outputs.feature_maps

            a_    :     Tuple										=    self.decode_head(lowerCamelCase_    )
            a_    :     Optional[Any]										=    nn.functional.interpolate(lowerCamelCase_      ,							size=pixel_values.shape[2:]      ,							mode="""bilinear"""      ,							align_corners=lowerCamelCase_    )

            a_    :     List[Any]										=    None
            if self.auxiliary_head is not None:
                 a_    :     Dict										=    self.auxiliary_head(lowerCamelCase_    )
                 a_    :     List[Any]										=    nn.functional.interpolate(
                     lowerCamelCase_      ,							size=pixel_values.shape[2:]      ,							mode="""bilinear"""      ,							align_corners=lowerCamelCase_    )

            a_    :     Dict										=    None
            if labels is not None:
                 if self.config.num_labels == 1:
                      raise ValueError("""The number of labels should be greater than one"""    )
                 else:
                      # compute weighted loss
                      a_    :     int										=    CrossEntropyLoss(ignore_index=self.config.loss_ignore_index    )
                      a_    :     List[Any]										=    loss_fct(lowerCamelCase_      ,							lowerCamelCase_    )
                      a_    :     Optional[int]										=    loss_fct(lowerCamelCase_      ,							lowerCamelCase_    )
                      a_    :     Tuple										=    main_loss + self.config.auxiliary_loss_weight * auxiliary_loss

            if not return_dict:
                 if output_hidden_states:
                      a_    :     str										=    (logits,) + outputs[1:]
                 else:
                      a_    :     Optional[int]										=    (logits,) + outputs[2:]
                 return ((loss,) + output) if loss is not None else output

            return SemanticSegmenterOutput(
                loss=lowerCamelCase_      ,							logits=lowerCamelCase_      ,							hidden_states=outputs.hidden_states      ,							attentions=outputs.attentions      ,							)







import os
import re
import shutil
import sys
import tempfile
import unittest

import black


__lowerCamelCase        =     os.path.abspath(os.path.dirname(os.path.dirname(os.path.dirname(__file__))))
sys.path.append(os.path.join(git_repo_path, '''utils'''))

import check_copies  # noqa: E402


# This is the reference code that will be used in the tests.
# If BertLMPredictionHead is changed in modeling_bert.py, this code needs to be manually updated.
__lowerCamelCase        =     '''    def __init__(self, config):
        super().__init__()
        self.transform = BertPredictionHeadTransform(config)

        # The output weights are the same as the input embeddings, but there is
        # an output-only bias for each token.
        self.decoder = nn.Linear(config.hidden_size, config.vocab_size, bias=False)

        self.bias = nn.Parameter(torch.zeros(config.vocab_size))

        # Need a link between the two variables so that the bias is correctly resized with `resize_token_embeddings`
        self.decoder.bias = self.bias

    def forward(self, hidden_states):
        hidden_states = self.transform(hidden_states)
        hidden_states = self.decoder(hidden_states)
        return hidden_states
'''


class   a__	(						unittest.TestCase    ):

       def 						UpperCAmelCase(   self      :     Dict    ):
            a_    :     Optional[Any]										=    tempfile.mkdtemp()
            os.makedirs(os.path.join(self.transformer_dir      ,							"""models/bert/"""    )    )
            a_    :     Optional[Any]										=    self.transformer_dir
            shutil.copy(
                os.path.join(lowerCamelCase_      ,							"""src/transformers/models/bert/modeling_bert.py"""    )      ,							os.path.join(self.transformer_dir      ,							"""models/bert/modeling_bert.py"""    )      ,							)

       def 						UpperCAmelCase(   self      :     Dict    ):
            a_    :     Any										=    """src/transformers"""
            shutil.rmtree(self.transformer_dir    )

       def 						UpperCAmelCase(   self      :     Dict      ,							lowerCamelCase_      :     str      ,							lowerCamelCase_      :     Optional[int]      ,							lowerCamelCase_      :     int      ,							lowerCamelCase_      :     Tuple=None    ):
            a_    :     Any										=    comment + F'''\nclass {class_name}(nn.Module):\n''' + class_code
            if overwrite_result is not None:
                 a_    :     Any										=    comment + F'''\nclass {class_name}(nn.Module):\n''' + overwrite_result
            a_    :     Dict										=    black.Mode(target_versions={black.TargetVersion.PYaa}      ,							line_length=1_1_9    )
            a_    :     Optional[Any]										=    black.format_str(lowerCamelCase_      ,							mode=lowerCamelCase_    )
            a_    :     Optional[Any]										=    os.path.join(self.transformer_dir      ,							"""new_code.py"""    )
            with open(lowerCamelCase_      ,							"""w"""      ,							newline="""\n"""    ) as f:
                 f.write(lowerCamelCase_    )
            if overwrite_result is None:
                 self.assertTrue(len(check_copies.is_copy_consistent(lowerCamelCase_    )    ) == 0    )
            else:
                 check_copies.is_copy_consistent(f.name      ,							overwrite=lowerCamelCase_    )
                 with open(lowerCamelCase_      ,							"""r"""    ) as f:
                      self.assertTrue(f.read()      ,							lowerCamelCase_    )

       def 						UpperCAmelCase(   self      :     Dict    ):
            a_    :     Tuple										=    check_copies.find_code_in_transformers("""models.bert.modeling_bert.BertLMPredictionHead"""    )
            self.assertEqual(lowerCamelCase_      ,							lowerCamelCase_    )

       def 						UpperCAmelCase(   self      :     Optional[int]    ):
            # Base copy consistency
            self.check_copy_consistency(
                """# Copied from transformers.models.bert.modeling_bert.BertLMPredictionHead"""      ,							"""BertLMPredictionHead"""      ,							REFERENCE_CODE + """\n"""      ,							)

            # With no empty line at the end
            self.check_copy_consistency(
                """# Copied from transformers.models.bert.modeling_bert.BertLMPredictionHead"""      ,							"""BertLMPredictionHead"""      ,							lowerCamelCase_      ,							)

            # Copy consistency with rename
            self.check_copy_consistency(
                """# Copied from transformers.models.bert.modeling_bert.BertLMPredictionHead with Bert->TestModel"""      ,							"""TestModelLMPredictionHead"""      ,							re.sub("""Bert"""      ,							"""TestModel"""      ,							lowerCamelCase_    )      ,							)

            # Copy consistency with a really long name
            a_    :     int										=    """TestModelWithAReallyLongNameBecauseSomePeopleLikeThatForSomeReason"""
            self.check_copy_consistency(
                F'''# Copied from transformers.models.bert.modeling_bert.BertLMPredictionHead with Bert->{long_class_name}'''      ,							F'''{long_class_name}LMPredictionHead'''      ,							re.sub("""Bert"""      ,							lowerCamelCase_      ,							lowerCamelCase_    )      ,							)

            # Copy consistency with overwrite
            self.check_copy_consistency(
                """# Copied from transformers.models.bert.modeling_bert.BertLMPredictionHead with Bert->TestModel"""      ,							"""TestModelLMPredictionHead"""      ,							lowerCamelCase_      ,							overwrite_result=re.sub("""Bert"""      ,							"""TestModel"""      ,							lowerCamelCase_    )      ,							)

       def 						UpperCAmelCase(   self      :     int    ):
            a_    :     Optional[Any]										=    check_copies.LOCALIZED_READMES["""README_zh-hans.md"""]

            a_    :     Tuple										=    (
                """1. **[ALBERT](https://huggingface.co/transformers/model_doc/albert.html)** (from Google Research and the"""
                """ Toyota Technological Institute at Chicago) released with the paper [ALBERT: A Lite BERT for"""
                """ Self-supervised Learning of Language Representations](https://arxiv.org/abs/1909.11942), by Zhenzhong"""
                """ Lan, Mingda Chen, Sebastian Goodman, Kevin Gimpel, Piyush Sharma, Radu Soricut.\n1."""
                """ **[DistilBERT](https://huggingface.co/transformers/model_doc/distilbert.html)** (from HuggingFace),"""
                """ released together with the paper [DistilBERT, a distilled version of BERT: smaller, faster, cheaper and"""
                """ lighter](https://arxiv.org/abs/1910.01108) by Victor Sanh, Lysandre Debut and Thomas Wolf. The same"""
                """ method has been applied to compress GPT2 into"""
                """ [DistilGPT2](https://github.com/huggingface/transformers/tree/main/examples/distillation), RoBERTa into"""
                """ [DistilRoBERTa](https://github.com/huggingface/transformers/tree/main/examples/distillation),"""
                """ Multilingual BERT into"""
                """ [DistilmBERT](https://github.com/huggingface/transformers/tree/main/examples/distillation) and a German"""
                """ version of DistilBERT.\n1. **[ELECTRA](https://huggingface.co/transformers/model_doc/electra.html)**"""
                """ (from Google Research/Stanford University) released with the paper [ELECTRA: Pre-training text encoders"""
                """ as discriminators rather than generators](https://arxiv.org/abs/2003.10555) by Kevin Clark, Minh-Thang"""
                """ Luong, Quoc V. Le, Christopher D. Manning."""
            )
            a_    :     Optional[Any]										=    (
                """1. **[ALBERT](https://huggingface.co/transformers/model_doc/albert.html)** (来自 Google Research and the"""
                """ Toyota Technological Institute at Chicago) 伴随论文 [ALBERT: A Lite BERT for Self-supervised Learning of"""
                """ Language Representations](https://arxiv.org/abs/1909.11942), 由 Zhenzhong Lan, Mingda Chen, Sebastian"""
                """ Goodman, Kevin Gimpel, Piyush Sharma, Radu Soricut 发布。\n"""
            )
            a_    :     Any										=    (
                """1. **[ALBERT](https://huggingface.co/transformers/model_doc/albert.html)** (来自 Google Research and the"""
                """ Toyota Technological Institute at Chicago) 伴随论文 [ALBERT: A Lite BERT for Self-supervised Learning of"""
                """ Language Representations](https://arxiv.org/abs/1909.11942), 由 Zhenzhong Lan, Mingda Chen, Sebastian"""
                """ Goodman, Kevin Gimpel, Piyush Sharma, Radu Soricut 发布。\n1."""
                """ **[DistilBERT](https://huggingface.co/transformers/model_doc/distilbert.html)** (来自 HuggingFace) 伴随论文"""
                """ [DistilBERT, a distilled version of BERT: smaller, faster, cheaper and"""
                """ lighter](https://arxiv.org/abs/1910.01108) 由 Victor Sanh, Lysandre Debut and Thomas Wolf 发布。 The same"""
                """ method has been applied to compress GPT2 into"""
                """ [DistilGPT2](https://github.com/huggingface/transformers/tree/main/examples/distillation), RoBERTa into"""
                """ [DistilRoBERTa](https://github.com/huggingface/transformers/tree/main/examples/distillation),"""
                """ Multilingual BERT into"""
                """ [DistilmBERT](https://github.com/huggingface/transformers/tree/main/examples/distillation) and a German"""
                """ version of DistilBERT.\n1. **[ELECTRA](https://huggingface.co/transformers/model_doc/electra.html)** (来自"""
                """ Google Research/Stanford University) 伴随论文 [ELECTRA: Pre-training text encoders as discriminators rather"""
                """ than generators](https://arxiv.org/abs/2003.10555) 由 Kevin Clark, Minh-Thang Luong, Quoc V. Le,"""
                """ Christopher D. Manning 发布。\n"""
            )

            a_			,			a_    :     Optional[int]										=    check_copies.convert_to_localized_md(
                lowerCamelCase_      ,							lowerCamelCase_      ,							localized_readme["""format_model_list"""]    )

            self.assertFalse(lowerCamelCase_    )
            self.assertEqual(lowerCamelCase_      ,							lowerCamelCase_    )

            a_			,			a_    :     Tuple										=    check_copies.convert_to_localized_md(
                lowerCamelCase_      ,							lowerCamelCase_      ,							localized_readme["""format_model_list"""]    )

            # Check whether the number of models is equal to README.md after conversion.
            self.assertTrue(lowerCamelCase_    )

            a_    :     Optional[int]										=    (
                """1. **[ALBERT](https://huggingface.co/transformers/model_doc/albert.html)** (from Google Research and the"""
                """ Toyota Technological Institute at Chicago) released with the paper [ALBERT: A Lite BERT for"""
                """ Self-supervised Learning of Language Representations](https://arxiv.org/abs/1909.11942), by Zhenzhong"""
                """ Lan, Mingda Chen, Sebastian Goodman, Kevin Gimpel, Piyush Sharma, Radu Soricut."""
            )
            a_    :     Union[str, Any]										=    (
                """1. **[ALBERT](https://huggingface.co/transformers/main/model_doc/albert.html)** (来自 Google Research and"""
                """ the Toyota Technological Institute at Chicago) 伴随论文 [ALBERT: A Lite BERT for Self-supervised Learning of"""
                """ Language Representations](https://arxiv.org/abs/1909.11942), 由 Zhenzhong Lan, Mingda Chen, Sebastian"""
                """ Goodman, Kevin Gimpel, Piyush Sharma, Radu Soricut 发布。\n"""
            )
            a_    :     str										=    (
                """1. **[ALBERT](https://huggingface.co/transformers/model_doc/albert.html)** (来自 Google Research and the"""
                """ Toyota Technological Institute at Chicago) 伴随论文 [ALBERT: A Lite BERT for Self-supervised Learning of"""
                """ Language Representations](https://arxiv.org/abs/1909.11942), 由 Zhenzhong Lan, Mingda Chen, Sebastian"""
                """ Goodman, Kevin Gimpel, Piyush Sharma, Radu Soricut 发布。\n"""
            )

            a_			,			a_    :     Tuple										=    check_copies.convert_to_localized_md(
                lowerCamelCase_      ,							lowerCamelCase_      ,							localized_readme["""format_model_list"""]    )

            # Check if the model link is synchronized.
            self.assertEqual(lowerCamelCase_      ,							lowerCamelCase_    )



