code: 
  '''simple docstring'''
  
  import inspect
  import unittest
  
  from transformers import is_torch_available, is_vision_available
  from transformers.models.auto import get_values
  from transformers.testing_utils import require_torch, slow, torch_device
  
  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 transformers import MODEL_MAPPING, PoolFormerConfig, PoolFormerForImageClassification, PoolFormerModel
  	from transformers.models.poolformer.modeling_poolformer import POOLFORMER_PRETRAINED_MODEL_ARCHIVE_LIST
  
  
  if is_vision_available():
  	from PIL import Image
  
  	from transformers import PoolFormerImageProcessor
  
  class 			UpperCAmelCase				(					a_ ):
  
  
  
  
  
  		"""simple docstring"""
  
  
  
  
  
  		def _lowercase  (    self     )				->    Union[str, Any]:
  				_UpperCamelCase       : Optional[int]    =      self.config_class(**self.inputs_dict     )
  				self.parent.assertTrue(hasattr(_snake_case  ,					'''hidden_sizes'''     )     )
  				self.parent.assertTrue(hasattr(_snake_case  ,					'''num_encoder_blocks'''     )     )
  
  
  
  
  
  
  
  class 			UpperCAmelCase				:
  
  
  
  
  
  		"""simple docstring"""
  
  
  
  
  
  		def __init__(    self  ,					_snake_case  ,					_snake_case=13  ,					_snake_case=64  ,					_snake_case=3  ,					_snake_case=4  ,					_snake_case=[2, 2, 2, 2]  ,					_snake_case=[8, 4, 2, 1]  ,					_snake_case=[16, 32, 64, 128]  ,					_snake_case=[1, 4, 8, 16]  ,					_snake_case=False  ,					_snake_case=True  ,					_snake_case="gelu"  ,					_snake_case=0.1  ,					_snake_case=0.02  ,					_snake_case=3  ,					_snake_case=None  ,					)				->    List[Any]:
  				_UpperCamelCase       : Union[str, Any]    =      parent
  				_UpperCamelCase       : Optional[int]    =      batch_size
  				_UpperCamelCase       : int    =      image_size
  				_UpperCamelCase       : List[Any]    =      num_channels
  				_UpperCamelCase       : Optional[Any]    =      num_encoder_blocks
  				_UpperCamelCase       : Any    =      sr_ratios
  				_UpperCamelCase       : Any    =      depths
  				_UpperCamelCase       : str    =      hidden_sizes
  				_UpperCamelCase       : Dict    =      downsampling_rates
  				_UpperCamelCase       : Union[str, Any]    =      is_training
  				_UpperCamelCase       : Optional[int]    =      use_labels
  				_UpperCamelCase       : str    =      hidden_act
  				_UpperCamelCase       : Dict    =      hidden_dropout_prob
  				_UpperCamelCase       : Any    =      initializer_range
  				_UpperCamelCase       : Union[str, Any]    =      num_labels
  				_UpperCamelCase       : Dict    =      scope
  		def _lowercase  (    self     )				->    Tuple:
  				_UpperCamelCase       : Dict    =      floats_tensor([self.batch_size, self.num_channels, self.image_size, self.image_size]     )
  
  				_UpperCamelCase       : List[Any]    =      None
  				if self.use_labels:
  						_UpperCamelCase       : Optional[int]    =      ids_tensor([self.batch_size, self.image_size, self.image_size]  ,					self.num_labels     )
  
  				_UpperCamelCase       : str    =      PoolFormerConfig(
  				    image_size=self.image_size  ,					num_channels=self.num_channels  ,					num_encoder_blocks=self.num_encoder_blocks  ,					depths=self.depths  ,					hidden_sizes=self.hidden_sizes  ,					hidden_act=self.hidden_act  ,					hidden_dropout_prob=self.hidden_dropout_prob  ,					initializer_range=self.initializer_range  ,					)
  
  				return config, pixel_values, labels
  		def _lowercase  (    self  ,					_snake_case  ,					_snake_case  ,					_snake_case     )				->    Optional[Any]:
  				_UpperCamelCase       : int    =      PoolFormerModel(config=_snake_case     )
  				model.to(_snake_case     )
  				model.eval()
  				_UpperCamelCase       : Tuple    =      model(_snake_case     )
  				_UpperCamelCase       : str    =      self.image_size // 32.0
  				self.parent.assertEqual(
  				    result.last_hidden_state.shape  ,					(self.batch_size, self.hidden_sizes[-1], expected_height, expected_width)     )
  
  
  
  
  		def _lowercase  (    self     )				->    Optional[Any]:
  				_UpperCamelCase       : List[str]    =      self.prepare_config_and_inputs()
  				_UpperCamelCase,							_UpperCamelCase,							_UpperCamelCase       : Tuple    =      config_and_inputs
  				_UpperCamelCase       : List[Any]    =      {'''pixel_values''': pixel_values}
  				return config, inputs_dict
  
  
  
  
  
  
  
  @require_torch
  class 			UpperCAmelCase				(					a_  ,		a_  ,		unittest.TestCase ):
  
  
  
  
  
  		"""simple docstring"""
  
  
  
  
  
  		A__  :   Optional[Any]          =    (PoolFormerModel, PoolFormerForImageClassification) if is_torch_available() else ()
  		A__  :   List[Any]          =    (
  		    {'feature-extraction': PoolFormerModel, 'image-classification': PoolFormerForImageClassification}
  		    if is_torch_available()
  		    else {}
  		)
  
  		A__  :   Tuple          =    False
  		A__  :   Tuple          =    False
  		A__  :   Optional[Any]          =    False
  		A__  :   Optional[Any]          =    False
  		A__  :   Optional[Any]          =    False
  		def _lowercase  (    self     )				->    List[str]:
  				_UpperCamelCase       : Union[str, Any]    =      PoolFormerModelTester(self     )
  				_UpperCamelCase       : Any    =      PoolFormerConfigTester(self  ,					config_class=_snake_case     )
  		def _lowercase  (    self     )				->    Any:
  				self.config_tester.run_common_tests()
  		def _lowercase  (    self     )				->    Optional[int]:
  				_UpperCamelCase       : Optional[Any]    =      self.model_tester.prepare_config_and_inputs()
  				self.model_tester.create_and_check_model(*_snake_case     )
  		@unittest.skip('''PoolFormer does not use inputs_embeds'''     )
  		def _lowercase  (    self     )				->    Optional[int]:
  				pass
  		@unittest.skip('''PoolFormer does not have get_input_embeddings method and get_output_embeddings methods'''     )
  		def _lowercase  (    self     )				->    Dict:
  				pass
  		def _lowercase  (    self     )				->    str:
  
  
  
  
  
  
  
  				def check_hidden_states_output(_snake_case  ,					_snake_case  ,					_snake_case     ):
  						_UpperCamelCase       : Any    =      model_class(_snake_case     )
  						model.to(_snake_case     )
  						model.eval()
  
  						with torch.no_grad():
  								_UpperCamelCase       : List[Any]    =      model(**self._prepare_for_class(_snake_case  ,					_snake_case     )     )
  
  						_UpperCamelCase       : Optional[Any]    =      outputs.hidden_states
  
  						_UpperCamelCase       : List[Any]    =      self.model_tester.num_encoder_blocks
  						self.assertEqual(len(_snake_case     )  ,					_snake_case     )
  
  						# verify the first hidden states (first block)
  						self.assertListEqual(
  						    list(hidden_states[0].shape[-3:]     )  ,					[
  						        self.model_tester.hidden_sizes[0],
  						        self.model_tester.image_size // 4,
  						        self.model_tester.image_size // 4,
  						    ]  ,					)
  
  				_UpperCamelCase,							_UpperCamelCase       : List[str]    =      self.model_tester.prepare_config_and_inputs_for_common()
  
  				for model_class in self.all_model_classes:
  						_UpperCamelCase       : Optional[Any]    =      True
  						check_hidden_states_output(_snake_case  ,					_snake_case  ,					_snake_case     )
  
  						# check that output_hidden_states also work using config
  						del inputs_dict["output_hidden_states"]
  						_UpperCamelCase       : str    =      True
  
  						check_hidden_states_output(_snake_case  ,					_snake_case  ,					_snake_case     )
  		def _lowercase  (    self     )				->    List[str]:
  
  
  
  
  
  
  
  				if not self.model_tester.is_training:
  						return
  
  				_UpperCamelCase,							_UpperCamelCase       : Dict    =      self.model_tester.prepare_config_and_inputs_for_common()
  				_UpperCamelCase       : List[str]    =      True
  
  				for model_class in self.all_model_classes:
  						if model_class in get_values(_snake_case     ):
  								continue
  						_UpperCamelCase       : Optional[Any]    =      model_class(_snake_case     )
  						model.to(_snake_case     )
  						model.train()
  						_UpperCamelCase       : Union[str, Any]    =      self._prepare_for_class(_snake_case  ,					_snake_case  ,					return_labels=_snake_case     )
  						_UpperCamelCase       : List[Any]    =      model(**_snake_case     ).loss
  						loss.backward()
  		def _lowercase  (    self     )				->    Any:
  				_UpperCamelCase,							_UpperCamelCase       : Optional[int]    =      self.model_tester.prepare_config_and_inputs_for_common()
  
  				for model_class in self.all_model_classes:
  						_UpperCamelCase       : str    =      model_class(_snake_case     )
  						_UpperCamelCase       : Union[str, Any]    =      inspect.signature(model.forward     )
  						# signature.parameters is an OrderedDict => so arg_names order is deterministic
  						_UpperCamelCase       : Optional[Any]    =      [*signature.parameters.keys()]
  
  						_UpperCamelCase       : Any    =      ['''pixel_values''']
  						self.assertListEqual(arg_names[:1]  ,					_snake_case     )
  
  
  
  
  		@slow
  		def _lowercase  (    self     )				->    List[str]:
  
  
  
  
  
  
  
  				for model_name in POOLFORMER_PRETRAINED_MODEL_ARCHIVE_LIST[:1]:
  						_UpperCamelCase       : Optional[Any]    =      PoolFormerModel.from_pretrained(_snake_case     )
  						self.assertIsNotNone(_snake_case     )
  
  
  
  
  
  
  
  def 						snake_case__	(      ) ->      Dict:
  		_UpperCamelCase       : str    =      Image.open('''./tests/fixtures/tests_samples/COCO/000000039769.png'''	)
  		return image
  
  
  @require_torch
  class 			UpperCAmelCase				(					unittest.TestCase ):
  
  
  
  
  
  		"""simple docstring"""
  
  
  
  
  
  		@slow
  		def _lowercase  (    self     )				->    Dict:
  				_UpperCamelCase       : Tuple    =      PoolFormerImageProcessor()
  				_UpperCamelCase       : Tuple    =      PoolFormerForImageClassification.from_pretrained('''sail/poolformer_s12'''     ).to(_snake_case     )
  
  				_UpperCamelCase       : Optional[int]    =      image_processor(images=prepare_img()  ,					return_tensors='''pt'''     ).to(_snake_case     )
  
  				# forward pass
  				with torch.no_grad():
  						_UpperCamelCase       : int    =      model(**_snake_case     )
  
  				# verify the logits
  				_UpperCamelCase       : List[Any]    =      torch.Size((1, 1000)     )
  				self.assertEqual(outputs.logits.shape  ,					_snake_case     )
  
  				_UpperCamelCase       : List[Any]    =      torch.tensor([-0.6_113, 0.1_685, -0.0_492]     ).to(_snake_case     )
  				self.assertTrue(torch.allclose(outputs.logits[0, :3]  ,					_snake_case  ,					atol=1E-4     )     )
  
  
  
  
  
  
style_context: 
  '''simple docstring'''
  
  import os
  
  
  
  
  
  
  
  def 						snake_case__	(      ) ->      Tuple:
  		_UpperCamelCase       : Dict    =      os.path.dirname(os.path.realpath(UpperCamelCase	)	)
  		_UpperCamelCase       : str    =      os.path.join(UpperCamelCase			,'''triangle.txt'''	)
  
  		with open(UpperCamelCase	) as f:
  				_UpperCamelCase       : Optional[Any]    =      f.readlines()
  
  		_UpperCamelCase       : List[str]    =      [[int(UpperCamelCase	) for y in x.rstrip('''\r\n'''	).split(''' '''	)] for x in triangle]
  
  		for i in range(1			,len(UpperCamelCase	)	):
  				for j in range(len(a[i]	)	):
  						_UpperCamelCase       : str    =      a[i - 1][j] if j != len(a[i - 1]	) else 0
  						_UpperCamelCase       : Any    =      a[i - 1][j - 1] if j > 0 else 0
  						a[i][j] += max(UpperCamelCase			,UpperCamelCase	)
  		return max(a[-1]	)
  
  
  if __name__ == "__main__":
  	print(solution())
  
  
  
  
  
  