code: 
  
  import unittest
  
  import numpy as np
  from datasets import load_dataset
  
  from transformers.testing_utils import require_torch, require_vision
  from transformers.utils import is_torch_available, is_vision_available
  
  from ...test_image_processing_common import ImageProcessingSavingTestMixin, prepare_image_inputs
  
  
  if is_torch_available():
  					import torch
  
  if is_vision_available():
  					from PIL import Image
  
  					from transformers import SegformerImageProcessor
  
  class __UpperCamelCase    (							unittest.TestCase		):
  
  
  
  
  
  
  					'''simple docstring'''
  
  
  
  					def __init__(							self							,			lowerCamelCase__							,			lowerCamelCase__=7							,			lowerCamelCase__=3							,			lowerCamelCase__=3_0							,			lowerCamelCase__=4_0_0							,			lowerCamelCase__=True							,			lowerCamelCase__=None							,			lowerCamelCase__=True							,			lowerCamelCase__=[0.5, 0.5, 0.5]							,			lowerCamelCase__=[0.5, 0.5, 0.5]							,			lowerCamelCase__=False							,			):
  						UpperCAmelCase__:  Optional[Any]		       =   size if size is not None else {"height": 3_0, "width": 3_0}
  						UpperCAmelCase__:  str		       =   parent
  						UpperCAmelCase__:  Tuple		       =   batch_size
  						UpperCAmelCase__:  int		       =   num_channels
  						UpperCAmelCase__:  List[str]		       =   min_resolution
  						UpperCAmelCase__:  int		       =   max_resolution
  						UpperCAmelCase__:  str		       =   do_resize
  						UpperCAmelCase__:  Optional[Any]		       =   size
  						UpperCAmelCase__:  Dict		       =   do_normalize
  						UpperCAmelCase__:  Union[str, Any]		       =   image_mean
  						UpperCAmelCase__:  List[Any]		       =   image_std
  						UpperCAmelCase__:  int		       =   do_reduce_labels
  
  
  
  
  
  					def       _UpperCAmelCase						(							self	):
  						return {
  						    "do_resize": self.do_resize,
  						    "size": self.size,
  						    "do_normalize": self.do_normalize,
  						    "image_mean": self.image_mean,
  						    "image_std": self.image_std,
  						    "do_reduce_labels": self.do_reduce_labels,
  						}
  
  
  
  def  _A  (			):
  	UpperCAmelCase__:  Optional[int]		       =   load_dataset("hf-internal-testing/fixtures_ade20k"  ,split="test"			)
  
  	UpperCAmelCase__:  List[str]		       =   Image.open(dataset[0]["file"]			)
  	UpperCAmelCase__:  List[Any]		       =   Image.open(dataset[1]["file"]			)
  
  	return image, map
  
  
  
  def  _A  (			):
  	UpperCAmelCase__:  List[Any]		       =   load_dataset("hf-internal-testing/fixtures_ade20k"  ,split="test"			)
  
  	UpperCAmelCase__:  str		       =   Image.open(dataset[0]["file"]			)
  	UpperCAmelCase__:  List[str]		       =   Image.open(dataset[1]["file"]			)
  	UpperCAmelCase__:  int		       =   Image.open(dataset[2]["file"]			)
  	UpperCAmelCase__:  str		       =   Image.open(dataset[3]["file"]			)
  
  	return [imagea, imagea], [mapa, mapa]
  
  @require_torch
  @require_vision
  class __UpperCamelCase    (							_a				,unittest.TestCase		):
  
  
  
  
  
  
  					'''simple docstring'''
  
  
  
  					__magic_name__     			=      SegformerImageProcessor if is_vision_available() else None
  
  
  
  
  
  					def       _UpperCAmelCase						(							self	):
  						UpperCAmelCase__:  List[Any]		       =   SegformerImageProcessingTester(self	)
  
  
  
  
  
  					@property
  					def       _UpperCAmelCase						(							self	):
  						return self.image_processor_tester.prepare_image_processor_dict()
  
  
  
  
  
  					def       _UpperCAmelCase						(							self	):
  						UpperCAmelCase__:  str		       =   self.image_processing_class(**self.image_processor_dict	)
  						self.assertTrue(hasattr(lowerCamelCase__							,			"do_resize"	)	)
  						self.assertTrue(hasattr(lowerCamelCase__							,			"size"	)	)
  						self.assertTrue(hasattr(lowerCamelCase__							,			"do_normalize"	)	)
  						self.assertTrue(hasattr(lowerCamelCase__							,			"image_mean"	)	)
  						self.assertTrue(hasattr(lowerCamelCase__							,			"image_std"	)	)
  						self.assertTrue(hasattr(lowerCamelCase__							,			"do_reduce_labels"	)	)
  
  
  
  
  
  					def       _UpperCAmelCase						(							self	):
  						UpperCAmelCase__:  int		       =   self.image_processing_class.from_dict(self.image_processor_dict	)
  						self.assertEqual(image_processor.size							,			{"height": 3_0, "width": 3_0}	)
  						self.assertEqual(image_processor.do_reduce_labels							,			lowerCamelCase__	)
  
  						UpperCAmelCase__:  List[Any]		       =   self.image_processing_class.from_dict(self.image_processor_dict							,			size=4_2							,			reduce_labels=lowerCamelCase__	)
  						self.assertEqual(image_processor.size							,			{"height": 4_2, "width": 4_2}	)
  						self.assertEqual(image_processor.do_reduce_labels							,			lowerCamelCase__	)
  
  
  
  
  
  					def       _UpperCAmelCase						(							self	):
  						pass
  
  
  
  
  
  					def       _UpperCAmelCase						(							self	):
  						# Initialize image_processing
  						UpperCAmelCase__:  Any		       =   self.image_processing_class(**self.image_processor_dict	)
  						# create random PIL images
  						UpperCAmelCase__:  Dict		       =   prepare_image_inputs(self.image_processor_tester							,			equal_resolution=lowerCamelCase__	)
  						for image in image_inputs:
  							self.assertIsInstance(lowerCamelCase__							,			Image.Image	)
  
  						# Test not batched input
  						UpperCAmelCase__:  Optional[Any]		       =   image_processing(image_inputs[0]							,			return_tensors="pt"	).pixel_values
  						self.assertEqual(
  						    encoded_images.shape							,			(
  						        1,
  						        self.image_processor_tester.num_channels,
  						        self.image_processor_tester.size["height"],
  						        self.image_processor_tester.size["width"],
  						    )							,			)
  
  						# Test batched
  						UpperCAmelCase__:  Any		       =   image_processing(lowerCamelCase__							,			return_tensors="pt"	).pixel_values
  						self.assertEqual(
  						    encoded_images.shape							,			(
  						        self.image_processor_tester.batch_size,
  						        self.image_processor_tester.num_channels,
  						        self.image_processor_tester.size["height"],
  						        self.image_processor_tester.size["width"],
  						    )							,			)
  
  
  
  
  
  					def       _UpperCAmelCase						(							self	):
  						# Initialize image_processing
  						UpperCAmelCase__:  Any		       =   self.image_processing_class(**self.image_processor_dict	)
  						# create random numpy tensors
  						UpperCAmelCase__:  str		       =   prepare_image_inputs(self.image_processor_tester							,			equal_resolution=lowerCamelCase__							,			numpify=lowerCamelCase__	)
  						for image in image_inputs:
  							self.assertIsInstance(lowerCamelCase__							,			np.ndarray	)
  
  						# Test not batched input
  						UpperCAmelCase__:  Tuple		       =   image_processing(image_inputs[0]							,			return_tensors="pt"	).pixel_values
  						self.assertEqual(
  						    encoded_images.shape							,			(
  						        1,
  						        self.image_processor_tester.num_channels,
  						        self.image_processor_tester.size["height"],
  						        self.image_processor_tester.size["width"],
  						    )							,			)
  
  						# Test batched
  						UpperCAmelCase__:  str		       =   image_processing(lowerCamelCase__							,			return_tensors="pt"	).pixel_values
  						self.assertEqual(
  						    encoded_images.shape							,			(
  						        self.image_processor_tester.batch_size,
  						        self.image_processor_tester.num_channels,
  						        self.image_processor_tester.size["height"],
  						        self.image_processor_tester.size["width"],
  						    )							,			)
  
  
  
  
  
  					def       _UpperCAmelCase						(							self	):
  						# Initialize image_processing
  						UpperCAmelCase__:  Tuple		       =   self.image_processing_class(**self.image_processor_dict	)
  						# create random PyTorch tensors
  						UpperCAmelCase__:  Optional[Any]		       =   prepare_image_inputs(self.image_processor_tester							,			equal_resolution=lowerCamelCase__							,			torchify=lowerCamelCase__	)
  						for image in image_inputs:
  							self.assertIsInstance(lowerCamelCase__							,			torch.Tensor	)
  
  						# Test not batched input
  						UpperCAmelCase__:  int		       =   image_processing(image_inputs[0]							,			return_tensors="pt"	).pixel_values
  						self.assertEqual(
  						    encoded_images.shape							,			(
  						        1,
  						        self.image_processor_tester.num_channels,
  						        self.image_processor_tester.size["height"],
  						        self.image_processor_tester.size["width"],
  						    )							,			)
  
  						# Test batched
  						UpperCAmelCase__:  Any		       =   image_processing(lowerCamelCase__							,			return_tensors="pt"	).pixel_values
  						self.assertEqual(
  						    encoded_images.shape							,			(
  						        self.image_processor_tester.batch_size,
  						        self.image_processor_tester.num_channels,
  						        self.image_processor_tester.size["height"],
  						        self.image_processor_tester.size["width"],
  						    )							,			)
  
  
  
  
  
  					def       _UpperCAmelCase						(							self	):
  						# Initialize image_processing
  						UpperCAmelCase__:  Dict		       =   self.image_processing_class(**self.image_processor_dict	)
  						# create random PyTorch tensors
  						UpperCAmelCase__:  Any		       =   prepare_image_inputs(self.image_processor_tester							,			equal_resolution=lowerCamelCase__							,			torchify=lowerCamelCase__	)
  						UpperCAmelCase__:  List[Any]		       =   []
  						for image in image_inputs:
  							self.assertIsInstance(lowerCamelCase__							,			torch.Tensor	)
  							maps.append(torch.zeros(image.shape[-2:]	).long()	)
  
  						# Test not batched input
  						UpperCAmelCase__:  Union[str, Any]		       =   image_processing(image_inputs[0]							,			maps[0]							,			return_tensors="pt"	)
  						self.assertEqual(
  						    encoding["pixel_values"].shape							,			(
  						        1,
  						        self.image_processor_tester.num_channels,
  						        self.image_processor_tester.size["height"],
  						        self.image_processor_tester.size["width"],
  						    )							,			)
  						self.assertEqual(
  						    encoding["labels"].shape							,			(
  						        1,
  						        self.image_processor_tester.size["height"],
  						        self.image_processor_tester.size["width"],
  						    )							,			)
  						self.assertEqual(encoding["labels"].dtype							,			torch.long	)
  						self.assertTrue(encoding["labels"].min().item() >= 0	)
  						self.assertTrue(encoding["labels"].max().item() <= 2_5_5	)
  
  						# Test batched
  						UpperCAmelCase__:  int		       =   image_processing(lowerCamelCase__							,			lowerCamelCase__							,			return_tensors="pt"	)
  						self.assertEqual(
  						    encoding["pixel_values"].shape							,			(
  						        self.image_processor_tester.batch_size,
  						        self.image_processor_tester.num_channels,
  						        self.image_processor_tester.size["height"],
  						        self.image_processor_tester.size["width"],
  						    )							,			)
  						self.assertEqual(
  						    encoding["labels"].shape							,			(
  						        self.image_processor_tester.batch_size,
  						        self.image_processor_tester.size["height"],
  						        self.image_processor_tester.size["width"],
  						    )							,			)
  						self.assertEqual(encoding["labels"].dtype							,			torch.long	)
  						self.assertTrue(encoding["labels"].min().item() >= 0	)
  						self.assertTrue(encoding["labels"].max().item() <= 2_5_5	)
  
  						# Test not batched input (PIL images)
  						UpperCAmelCase__       ,	UpperCAmelCase__:  List[Any]		       =   prepare_semantic_single_inputs()
  
  						UpperCAmelCase__:  Union[str, Any]		       =   image_processing(lowerCamelCase__							,			lowerCamelCase__							,			return_tensors="pt"	)
  						self.assertEqual(
  						    encoding["pixel_values"].shape							,			(
  						        1,
  						        self.image_processor_tester.num_channels,
  						        self.image_processor_tester.size["height"],
  						        self.image_processor_tester.size["width"],
  						    )							,			)
  						self.assertEqual(
  						    encoding["labels"].shape							,			(
  						        1,
  						        self.image_processor_tester.size["height"],
  						        self.image_processor_tester.size["width"],
  						    )							,			)
  						self.assertEqual(encoding["labels"].dtype							,			torch.long	)
  						self.assertTrue(encoding["labels"].min().item() >= 0	)
  						self.assertTrue(encoding["labels"].max().item() <= 2_5_5	)
  
  						# Test batched input (PIL images)
  						UpperCAmelCase__       ,	UpperCAmelCase__:  Any		       =   prepare_semantic_batch_inputs()
  
  						UpperCAmelCase__:  List[Any]		       =   image_processing(lowerCamelCase__							,			lowerCamelCase__							,			return_tensors="pt"	)
  						self.assertEqual(
  						    encoding["pixel_values"].shape							,			(
  						        2,
  						        self.image_processor_tester.num_channels,
  						        self.image_processor_tester.size["height"],
  						        self.image_processor_tester.size["width"],
  						    )							,			)
  						self.assertEqual(
  						    encoding["labels"].shape							,			(
  						        2,
  						        self.image_processor_tester.size["height"],
  						        self.image_processor_tester.size["width"],
  						    )							,			)
  						self.assertEqual(encoding["labels"].dtype							,			torch.long	)
  						self.assertTrue(encoding["labels"].min().item() >= 0	)
  						self.assertTrue(encoding["labels"].max().item() <= 2_5_5	)
  
  
  
  
  
  					def       _UpperCAmelCase						(							self	):
  						# Initialize image_processing
  						UpperCAmelCase__:  Dict		       =   self.image_processing_class(**self.image_processor_dict	)
  
  						# ADE20k has 150 classes, and the background is included, so labels should be between 0 and 150
  						UpperCAmelCase__       ,	UpperCAmelCase__:  str		       =   prepare_semantic_single_inputs()
  						UpperCAmelCase__:  Union[str, Any]		       =   image_processing(lowerCamelCase__							,			lowerCamelCase__							,			return_tensors="pt"	)
  						self.assertTrue(encoding["labels"].min().item() >= 0	)
  						self.assertTrue(encoding["labels"].max().item() <= 1_5_0	)
  
  						UpperCAmelCase__:  Tuple		       =   True
  						UpperCAmelCase__:  str		       =   image_processing(lowerCamelCase__							,			lowerCamelCase__							,			return_tensors="pt"	)
  						self.assertTrue(encoding["labels"].min().item() >= 0	)
  						self.assertTrue(encoding["labels"].max().item() <= 2_5_5	)
style_context: 
  
  import numpy as np
  
  
  
  def  _A  (			SCREAMING_SNAKE_CASE			):
  	UpperCAmelCase__:  List[Any]		       =   np.exp(SCREAMING_SNAKE_CASE			)
  
  	# Add up the all the exponentials
  	UpperCAmelCase__:  str		       =   np.sum(SCREAMING_SNAKE_CASE			)
  
  	# Divide every exponent by the sum of all exponents
  	UpperCAmelCase__:  Tuple		       =   exponent_vector / sum_of_exponents
  
  	return softmax_vector
  
  
  if __name__ == "__main__":
  					print(softmax((0,)))