


import argparse
import json
import os
import time
import zipfile

from get_ci_error_statistics import download_artifact, get_artifacts_links

from transformers import logging


lowerCAmelCase__      		= logging.get_logger(__name__)
def 							_UpperCAmelCase				(UpperCamelCase__     :  Tuple				,							UpperCamelCase__     :  Union[str, Any]						):
       _A      :       Dict				    = set()
       _A      :       Optional[int]				    = []

       def parse_line(UpperCamelCase__     :  Tuple						):
              for line in fp:
                     if isinstance(UpperCamelCase__				,							UpperCamelCase__						):
                            _A      :       str				    = line.decode("UTF-8"						)
                     if "warnings summary (final)" in line:
                            continue
                     # This means we are outside the body of a warning
                     elif not line.startswith(" "						):
                            # process a single warning and move it to `selected_warnings`.
                            if len(UpperCamelCase__						) > 0:
                                   _A      :       List[str]				    = "\n".join(UpperCamelCase__						)
                                   # Only keep the warnings specified in `targets`
                                   if any(f": {x}: " in warning for x in targets						):
                                          selected_warnings.add(UpperCamelCase__						)
                                   buffer.clear()
                            continue
                     else:
                            _A      :       Optional[int]				    = line.strip()
                            buffer.append(UpperCamelCase__						)

       if from_gh:
              for filename in os.listdir(UpperCamelCase__						):
                     _A      :       Tuple				    = os.path.join(UpperCamelCase__				,							UpperCamelCase__						)
                     if not os.path.isdir(UpperCamelCase__						):
                            # read the file
                            if filename != "warnings.txt":
                                   continue
                            with open(UpperCamelCase__						) as fp:
                                   parse_line(UpperCamelCase__						)
       else:
              try:
                     with zipfile.ZipFile(UpperCamelCase__						) as z:
                            for filename in z.namelist():
                                   if not os.path.isdir(UpperCamelCase__						):
                                          # read the file
                                          if filename != "warnings.txt":
                                                 continue
                                          with z.open(UpperCamelCase__						) as fp:
                                                 parse_line(UpperCamelCase__						)
              except Exception:
                     logger.warning(
                         f"{artifact_path} is either an invalid zip file or something else wrong. This file is skipped."						)

       return selected_warnings
def 							_UpperCAmelCase				(UpperCamelCase__     :  Any				,							UpperCamelCase__     :  List[Any]						):
       _A      :       int				    = set()

       _A      :       int				    = [os.path.join(UpperCamelCase__				,							UpperCamelCase__						) for p in os.listdir(UpperCamelCase__						) if (p.endswith(".zip"						) or from_gh)]
       for p in paths:
              selected_warnings.update(extract_warnings_from_single_artifact(UpperCamelCase__				,							UpperCamelCase__						)						)

       return selected_warnings


if __name__ == "__main__":
    def 							_UpperCAmelCase				(UpperCamelCase__     :  int						):
           return values.split(","						)

    lowerCAmelCase__      		= argparse.ArgumentParser()
    # Required parameters
    parser.add_argument('--workflow_run_id', type=str, required=True, help='A GitHub Actions workflow run id.')
    parser.add_argument(
        '--output_dir',
        type=str,
        required=True,
        help='Where to store the downloaded artifacts and other result files.',
    )
    parser.add_argument('--token', default=None, type=str, help='A token that has actions:read permission.')
    # optional parameters
    parser.add_argument(
        '--targets',
        default='DeprecationWarning,UserWarning,FutureWarning',
        type=list_str,
        help='Comma-separated list of target warning(s) which we want to extract.',
    )
    parser.add_argument(
        '--from_gh',
        action='store_true',
        help='If running from a GitHub action workflow and collecting warnings from its artifacts.',
    )

    lowerCAmelCase__      		= parser.parse_args()

    lowerCAmelCase__      		= args.from_gh
    if from_gh:
        # The artifacts have to be downloaded using `actions/download-artifact@v3`
        pass
    else:
        os.makedirs(args.output_dir, exist_ok=True)

        # get download links
        lowerCAmelCase__      		= get_artifacts_links(args.workflow_run_id, token=args.token)
        with open(os.path.join(args.output_dir, 'artifacts.json'), 'w', encoding='UTF-8') as fp:
            json.dump(artifacts, fp, ensure_ascii=False, indent=4)

        # download artifacts
        for idx, (name, url) in enumerate(artifacts.items()):
            print(name)
            print(url)
            print('=' * 80)
            download_artifact(name, url, args.output_dir, args.token)
            # Be gentle to GitHub
            time.sleep(1)

    # extract warnings from artifacts
    lowerCAmelCase__      		= extract_warnings(args.output_dir, args.targets)
    lowerCAmelCase__      		= sorted(selected_warnings)
    with open(os.path.join(args.output_dir, 'selected_warnings.json'), 'w', encoding='UTF-8') as fp:
        json.dump(selected_warnings, fp, ensure_ascii=False, indent=4)




import collections
import inspect
import unittest
from typing import Dict, List, Tuple

from transformers import MaskFormerSwinConfig
from transformers.testing_utils import require_torch, require_torch_multi_gpu, torch_device
from transformers.utils import is_torch_available

from ...test_backbone_common import BackboneTesterMixin
from ...test_configuration_common import ConfigTester
from ...test_modeling_common import ModelTesterMixin, floats_tensor, ids_tensor
from ...test_pipeline_mixin import PipelineTesterMixin


if is_torch_available():
    import torch
    from torch import nn

    from transformers import MaskFormerSwinBackbone
    from transformers.models.maskformer import MaskFormerSwinModel







class      lowerCAmelCase__       :




     '''simple docstring'''


     def __init__(						self ,						__lowerCamelCase ,						__lowerCamelCase=1_3 ,						__lowerCamelCase=3_2 ,						__lowerCamelCase=2 ,						__lowerCamelCase=3 ,						__lowerCamelCase=1_6 ,						__lowerCamelCase=[1, 2, 1] ,						__lowerCamelCase=[2, 2, 4] ,						__lowerCamelCase=2 ,						__lowerCamelCase=2.0 ,						__lowerCamelCase=True ,						__lowerCamelCase=0.0 ,						__lowerCamelCase=0.0 ,						__lowerCamelCase=0.1 ,						__lowerCamelCase="gelu" ,						__lowerCamelCase=False ,						__lowerCamelCase=True ,						__lowerCamelCase=0.0_2 ,						__lowerCamelCase=1e-5 ,						__lowerCamelCase=True ,						__lowerCamelCase=None ,						__lowerCamelCase=True ,						__lowerCamelCase=1_0 ,						__lowerCamelCase=8 ,						__lowerCamelCase=["stage1", "stage2", "stage3"] ,						__lowerCamelCase=[1, 2, 3] ,						)			->				Optional[Any]:
            _A      :       int				    = parent
            _A      :       Optional[Any]				    = batch_size
            _A      :       str				    = image_size
            _A      :       Tuple				    = patch_size
            _A      :       Tuple				    = num_channels
            _A      :       Optional[int]				    = embed_dim
            _A      :       Dict				    = depths
            _A      :       Any				    = num_heads
            _A      :       Any				    = window_size
            _A      :       int				    = mlp_ratio
            _A      :       Any				    = qkv_bias
            _A      :       Union[str, Any]				    = hidden_dropout_prob
            _A      :       Optional[Any]				    = attention_probs_dropout_prob
            _A      :       Dict				    = drop_path_rate
            _A      :       List[Any]				    = hidden_act
            _A      :       Any				    = use_absolute_embeddings
            _A      :       Optional[int]				    = patch_norm
            _A      :       Tuple				    = layer_norm_eps
            _A      :       List[str]				    = initializer_range
            _A      :       Optional[int]				    = is_training
            _A      :       Optional[Any]				    = scope
            _A      :       Optional[int]				    = use_labels
            _A      :       Dict				    = type_sequence_label_size
            _A      :       str				    = encoder_stride
            _A      :       Optional[int]				    = out_features
            _A      :       Optional[int]				    = out_indices


     def  _lowerCamelCase (						self)			->				Union[str, Any]:
            _A      :       List[str]				    = floats_tensor([self.batch_size, self.num_channels, self.image_size, self.image_size])

            _A      :       Optional[Any]				    = None
            if self.use_labels:
                   _A      :       Any				    = ids_tensor([self.batch_size] ,						self.type_sequence_label_size)

            _A      :       Optional[int]				    = self.get_config()

            return config, pixel_values, labels


     def  _lowerCamelCase (						self)			->				Union[str, Any]:
            return MaskFormerSwinConfig(
                image_size=self.image_size ,						patch_size=self.patch_size ,						num_channels=self.num_channels ,						embed_dim=self.embed_dim ,						depths=self.depths ,						num_heads=self.num_heads ,						window_size=self.window_size ,						mlp_ratio=self.mlp_ratio ,						qkv_bias=self.qkv_bias ,						hidden_dropout_prob=self.hidden_dropout_prob ,						attention_probs_dropout_prob=self.attention_probs_dropout_prob ,						drop_path_rate=self.drop_path_rate ,						hidden_act=self.hidden_act ,						use_absolute_embeddings=self.use_absolute_embeddings ,						path_norm=self.patch_norm ,						layer_norm_eps=self.layer_norm_eps ,						initializer_range=self.initializer_range ,						encoder_stride=self.encoder_stride ,						out_features=self.out_features ,						out_indices=self.out_indices ,						)


     def  _lowerCamelCase (						self ,						__lowerCamelCase ,						__lowerCamelCase ,						__lowerCamelCase)			->				List[Any]:
            _A      :       Dict				    = MaskFormerSwinModel(config=__lowerCamelCase)
            model.to(__lowerCamelCase)
            model.eval()
            _A      :       int				    = model(__lowerCamelCase)

            _A      :       Any				    = ((config.image_size // config.patch_size) ** 2) // (4 ** (len(config.depths) - 1))
            _A      :       List[str]				    = int(config.embed_dim * 2 ** (len(config.depths) - 1))

            self.parent.assertEqual(result.last_hidden_state.shape ,						(self.batch_size, expected_seq_len, expected_dim))


     def  _lowerCamelCase (						self ,						__lowerCamelCase ,						__lowerCamelCase ,						__lowerCamelCase)			->				Dict:
            _A      :       Optional[Any]				    = MaskFormerSwinBackbone(config=__lowerCamelCase)
            model.to(__lowerCamelCase)
            model.eval()
            _A      :       Dict				    = model(__lowerCamelCase)

            # verify feature maps
            self.parent.assertEqual(len(result.feature_maps) ,						len(config.out_features))
            self.parent.assertListEqual(list(result.feature_maps[0].shape) ,						[1_3, 1_6, 1_6, 1_6])

            # verify channels
            self.parent.assertEqual(len(model.channels) ,						len(config.out_features))
            self.parent.assertListEqual(model.channels ,						[1_6, 3_2, 6_4])

            # verify ValueError
            with self.parent.assertRaises(__lowerCamelCase):
                   _A      :       Union[str, Any]				    = ["stem"]
                   _A      :       Union[str, Any]				    = MaskFormerSwinBackbone(config=__lowerCamelCase)


     def  _lowerCamelCase (						self)			->				Dict:
            _A      :       Any				    = self.prepare_config_and_inputs()
            _A    ,			_A    ,			_A      :       List[Any]				    = config_and_inputs
            _A      :       Optional[int]				    = {"pixel_values": pixel_values}
            return config, inputs_dict







@require_torch
class      lowerCAmelCase__       (				a     ,    a     ,    unittest.TestCase):




     '''simple docstring'''
     __SCREAMING_SNAKE_CASE  			= (
         (
             MaskFormerSwinModel,
             MaskFormerSwinBackbone,
         )
         if is_torch_available()
         else ()
     )
     __SCREAMING_SNAKE_CASE  			= {"feature-extraction": MaskFormerSwinModel} if is_torch_available() else {}
     __SCREAMING_SNAKE_CASE  			= False
     __SCREAMING_SNAKE_CASE  			= False
     __SCREAMING_SNAKE_CASE  			= False
     __SCREAMING_SNAKE_CASE  			= False
     __SCREAMING_SNAKE_CASE  			= False


     def  _lowerCamelCase (						self)			->				str:
            _A      :       Union[str, Any]				    = MaskFormerSwinModelTester(self)
            _A      :       Optional[int]				    = ConfigTester(self ,						config_class=__lowerCamelCase ,						embed_dim=3_7)


     @require_torch_multi_gpu
     @unittest.skip(
         reason=(
             "`MaskFormerSwinModel` outputs `hidden_states_spatial_dimensions` which doesn't work well with"
             " `nn.DataParallel`"
         ))
     def  _lowerCamelCase (						self)			->				Union[str, Any]:
            pass


     def  _lowerCamelCase (						self)			->				int:
            self.create_and_test_config_common_properties()
            self.config_tester.create_and_test_config_to_json_string()
            self.config_tester.create_and_test_config_to_json_file()
            self.config_tester.create_and_test_config_from_and_save_pretrained()
            self.config_tester.create_and_test_config_with_num_labels()
            self.config_tester.check_config_can_be_init_without_params()
            self.config_tester.check_config_arguments_init()


     def  _lowerCamelCase (						self)			->				str:
            return


     def  _lowerCamelCase (						self)			->				List[Any]:
            _A      :       Optional[int]				    = self.model_tester.prepare_config_and_inputs()
            self.model_tester.create_and_check_model(*__lowerCamelCase)


     def  _lowerCamelCase (						self)			->				Union[str, Any]:
            _A      :       Any				    = self.model_tester.prepare_config_and_inputs()
            self.model_tester.create_and_check_backbone(*__lowerCamelCase)


     @unittest.skip("Swin does not use inputs_embeds")
     def  _lowerCamelCase (						self)			->				str:
            pass


     @unittest.skip("Swin does not support feedforward chunking")
     def  _lowerCamelCase (						self)			->				List[Any]:
            pass


     def  _lowerCamelCase (						self)			->				Optional[int]:
            _A    ,			_A      :       Union[str, Any]				    = self.model_tester.prepare_config_and_inputs_for_common()

            for model_class in self.all_model_classes:
                   _A      :       Union[str, Any]				    = model_class(__lowerCamelCase)
                   self.assertIsInstance(model.get_input_embeddings() ,						(nn.Module))
                   _A      :       Dict				    = model.get_output_embeddings()
                   self.assertTrue(x is None or isinstance(__lowerCamelCase ,						nn.Linear))


     def  _lowerCamelCase (						self)			->				Any:
            _A    ,			_A      :       List[Any]				    = self.model_tester.prepare_config_and_inputs_for_common()

            for model_class in self.all_model_classes:
                   _A      :       int				    = model_class(__lowerCamelCase)
                   _A      :       Optional[int]				    = inspect.signature(model.forward)
                   # signature.parameters is an OrderedDict => so arg_names order is deterministic
                   _A      :       int				    = [*signature.parameters.keys()]

                   _A      :       Optional[int]				    = ["pixel_values"]
                   self.assertListEqual(arg_names[:1] ,						__lowerCamelCase)


     @unittest.skip(reason="MaskFormerSwin is only used as backbone and doesn't support output_attentions")
     def  _lowerCamelCase (						self)			->				Tuple:
            pass


     @unittest.skip(reason="MaskFormerSwin is only used as an internal backbone")
     def  _lowerCamelCase (						self)			->				str:
            pass


     def  _lowerCamelCase (						self ,						__lowerCamelCase ,						__lowerCamelCase ,						__lowerCamelCase ,						__lowerCamelCase)			->				Optional[int]:
            _A      :       Any				    = model_class(__lowerCamelCase)
            model.to(__lowerCamelCase)
            model.eval()

            with torch.no_grad():
                   _A      :       str				    = model(**self._prepare_for_class(__lowerCamelCase ,						__lowerCamelCase))

            _A      :       Tuple				    = outputs.hidden_states

            _A      :       Any				    = getattr(
                self.model_tester ,						"expected_num_hidden_layers" ,						len(self.model_tester.depths) + 1)
            self.assertEqual(len(__lowerCamelCase) ,						__lowerCamelCase)

            # Swin has a different seq_length
            _A      :       Optional[int]				    = (
                config.patch_size
                if isinstance(config.patch_size ,						collections.abc.Iterable)
                else (config.patch_size, config.patch_size)
            )

            _A      :       str				    = (image_size[1] // patch_size[1]) * (image_size[0] // patch_size[0])

            self.assertListEqual(
                list(hidden_states[0].shape[-2:]) ,						[num_patches, self.model_tester.embed_dim] ,						)


     def  _lowerCamelCase (						self)			->				Dict:
            _A    ,			_A      :       List[str]				    = self.model_tester.prepare_config_and_inputs_for_common()

            _A      :       Any				    = (
                self.model_tester.image_size
                if isinstance(self.model_tester.image_size ,						collections.abc.Iterable)
                else (self.model_tester.image_size, self.model_tester.image_size)
            )

            for model_class in self.all_model_classes:
                   _A      :       List[Any]				    = True
                   self.check_hidden_states_output(__lowerCamelCase ,						__lowerCamelCase ,						__lowerCamelCase ,						__lowerCamelCase)

                   # check that output_hidden_states also work using config
                   del inputs_dict["output_hidden_states"]
                   _A      :       Optional[int]				    = True

                   self.check_hidden_states_output(__lowerCamelCase ,						__lowerCamelCase ,						__lowerCamelCase ,						__lowerCamelCase)


     def  _lowerCamelCase (						self)			->				Tuple:
            _A    ,			_A      :       List[str]				    = self.model_tester.prepare_config_and_inputs_for_common()
            _A      :       Optional[int]				    = 3

            _A      :       Dict				    = (
                self.model_tester.image_size
                if isinstance(self.model_tester.image_size ,						collections.abc.Iterable)
                else (self.model_tester.image_size, self.model_tester.image_size)
            )
            _A      :       Optional[int]				    = (
                config.patch_size
                if isinstance(config.patch_size ,						collections.abc.Iterable)
                else (config.patch_size, config.patch_size)
            )

            _A      :       int				    = image_size[0] + patch_size[0] - (image_size[0] % patch_size[0])
            _A      :       Dict				    = image_size[1] + patch_size[1] - (image_size[1] % patch_size[1])

            for model_class in self.all_model_classes:
                   _A      :       List[Any]				    = True
                   self.check_hidden_states_output(__lowerCamelCase ,						__lowerCamelCase ,						__lowerCamelCase ,						(padded_height, padded_width))

                   # check that output_hidden_states also work using config
                   del inputs_dict["output_hidden_states"]
                   _A      :       Union[str, Any]				    = True
                   self.check_hidden_states_output(__lowerCamelCase ,						__lowerCamelCase ,						__lowerCamelCase ,						(padded_height, padded_width))


     @unittest.skip(reason="MaskFormerSwin doesn't have pretrained checkpoints")
     def  _lowerCamelCase (						self)			->				List[str]:
            pass


     @unittest.skip(reason="This will be fixed once MaskFormerSwin is replaced by native Swin")
     def  _lowerCamelCase (						self)			->				List[str]:
            pass


     @unittest.skip(reason="This will be fixed once MaskFormerSwin is replaced by native Swin")
     def  _lowerCamelCase (						self)			->				str:
            pass


     def  _lowerCamelCase (						self)			->				Optional[Any]:
            _A    ,			_A      :       Any				    = self.model_tester.prepare_config_and_inputs_for_common()

            def set_nan_tensor_to_zero(__lowerCamelCase):
                   _A      :       Optional[int]				    = 0
                   return t

            def check_equivalence(__lowerCamelCase ,						__lowerCamelCase ,						__lowerCamelCase ,						__lowerCamelCase={}):
                   with torch.no_grad():
                          _A      :       Any				    = model(**__lowerCamelCase ,						return_dict=__lowerCamelCase ,						**__lowerCamelCase)
                          _A      :       int				    = model(**__lowerCamelCase ,						return_dict=__lowerCamelCase ,						**__lowerCamelCase).to_tuple()

                          def recursive_check(__lowerCamelCase ,						__lowerCamelCase):
                                 if isinstance(__lowerCamelCase ,						(List, Tuple)):
                                        for tuple_iterable_value, dict_iterable_value in zip(__lowerCamelCase ,						__lowerCamelCase):
                                               recursive_check(__lowerCamelCase ,						__lowerCamelCase)
                                 elif isinstance(__lowerCamelCase ,						__lowerCamelCase):
                                        for tuple_iterable_value, dict_iterable_value in zip(
                                            tuple_object.values() ,						dict_object.values()):
                                               recursive_check(__lowerCamelCase ,						__lowerCamelCase)
                                 elif tuple_object is None:
                                        return
                                 else:
                                        self.assertTrue(
                                            torch.allclose(
                                                set_nan_tensor_to_zero(__lowerCamelCase) ,						set_nan_tensor_to_zero(__lowerCamelCase) ,						atol=1e-5) ,						msg=(
                                                "Tuple and dict output are not equal. Difference:"
                                                F" {torch.max(torch.abs(tuple_object - dict_object))}. Tuple has `nan`:"
                                                F" {torch.isnan(__lowerCamelCase).any()} and `inf`: {torch.isinf(__lowerCamelCase)}. Dict has"
                                                F" `nan`: {torch.isnan(__lowerCamelCase).any()} and `inf`: {torch.isinf(__lowerCamelCase)}."
                                            ) ,						)

                          recursive_check(__lowerCamelCase ,						__lowerCamelCase)

            for model_class in self.all_model_classes:
                   _A      :       List[Any]				    = model_class(__lowerCamelCase)
                   model.to(__lowerCamelCase)
                   model.eval()

                   _A      :       str				    = self._prepare_for_class(__lowerCamelCase ,						__lowerCamelCase)
                   _A      :       Tuple				    = self._prepare_for_class(__lowerCamelCase ,						__lowerCamelCase)
                   check_equivalence(__lowerCamelCase ,						__lowerCamelCase ,						__lowerCamelCase)

                   _A      :       Any				    = self._prepare_for_class(__lowerCamelCase ,						__lowerCamelCase ,						return_labels=__lowerCamelCase)
                   _A      :       List[Any]				    = self._prepare_for_class(__lowerCamelCase ,						__lowerCamelCase ,						return_labels=__lowerCamelCase)
                   check_equivalence(__lowerCamelCase ,						__lowerCamelCase ,						__lowerCamelCase)

                   _A      :       List[Any]				    = self._prepare_for_class(__lowerCamelCase ,						__lowerCamelCase)
                   _A      :       str				    = self._prepare_for_class(__lowerCamelCase ,						__lowerCamelCase)
                   check_equivalence(__lowerCamelCase ,						__lowerCamelCase ,						__lowerCamelCase ,						{"output_hidden_states": True})

                   _A      :       Union[str, Any]				    = self._prepare_for_class(__lowerCamelCase ,						__lowerCamelCase ,						return_labels=__lowerCamelCase)
                   _A      :       Optional[Any]				    = self._prepare_for_class(__lowerCamelCase ,						__lowerCamelCase ,						return_labels=__lowerCamelCase)
                   check_equivalence(__lowerCamelCase ,						__lowerCamelCase ,						__lowerCamelCase ,						{"output_hidden_states": True})







@require_torch
class      lowerCAmelCase__       (				unittest.TestCase     ,    a):




     '''simple docstring'''
     __SCREAMING_SNAKE_CASE  			= (MaskFormerSwinBackbone,) if is_torch_available() else ()
     __SCREAMING_SNAKE_CASE  			= MaskFormerSwinConfig


     def  _lowerCamelCase (						self)			->				Optional[Any]:
            _A      :       Tuple				    = MaskFormerSwinModelTester(self)


     def  _lowerCamelCase (						self)			->				Optional[Any]:
            _A    ,			_A      :       List[Any]				    = self.model_tester.prepare_config_and_inputs_for_common()
            _A      :       Union[str, Any]				    = inputs_dict["pixel_values"].shape[0]

            for backbone_class in self.all_model_classes:
                   _A      :       Optional[Any]				    = backbone_class(__lowerCamelCase)
                   backbone.to(__lowerCamelCase)
                   backbone.eval()

                   _A      :       List[Any]				    = backbone(**__lowerCamelCase)

                   # Test default outputs and verify feature maps
                   self.assertIsInstance(outputs.feature_maps ,						__lowerCamelCase)
                   self.assertTrue(len(outputs.feature_maps) == len(backbone.channels))
                   for feature_map, n_channels in zip(outputs.feature_maps ,						backbone.channels):
                          self.assertTrue(feature_map.shape[:2] ,						(batch_size, n_channels))
                   self.assertIsNone(outputs.hidden_states)
                   self.assertIsNone(outputs.attentions)

                   # Test output_hidden_states=True
                   _A      :       List[str]				    = backbone(**__lowerCamelCase ,						output_hidden_states=__lowerCamelCase)
                   self.assertIsNotNone(outputs.hidden_states)
                   self.assertTrue(len(outputs.hidden_states) ,						len(backbone.stage_names))
                   # We skip the stem layer
                   for hidden_states, n_channels in zip(outputs.hidden_states[1:] ,						backbone.channels):
                          for hidden_state in hidden_states:
                                 # Hidden states are in the format (batch_size, (height * width), n_channels)
                                 _A    ,			_A    ,			_A      :       List[str]				    = hidden_state.shape
                                 self.assertTrue((h_batch_size, h_n_channels) ,						(batch_size, n_channels))

            # Test output_attentions=True
                   if self.has_attentions:
                          _A      :       int				    = backbone(**__lowerCamelCase ,						output_attentions=__lowerCamelCase)
                          self.assertIsNotNone(outputs.attentions)
