code: 
  
  
  from __future__ import annotations
  
  from queue import Queue
  def 							_UpperCAmelCase       (UpperCamelCase__  :						int       ,							UpperCamelCase__  :						int		):
         a ^= b
         b ^= a
         a ^= b
         return a, b
  def 							_UpperCAmelCase       (UpperCamelCase__  :						int       ,							UpperCamelCase__  :						list[list[int]]		):
         _A   : str       					=				1
         while (1 << j) < max_node:
                for i in range(1       ,							max_node + 1		):
                       _A   : List[str]       					=				parent[j - 1][parent[j - 1][i]]
                j += 1
         return parent
  def 							_UpperCAmelCase       (UpperCamelCase__  :						int       ,							UpperCamelCase__  :						int       ,							UpperCamelCase__  :						list[int]       ,							UpperCamelCase__  :						list[list[int]]		):
         # u must be deeper in the tree than v
         if level[u] < level[v]:
                _A					,    _A   : List[Any]       					=				swap(UpperCamelCase__       ,							UpperCamelCase__		)
         # making depth of u same as depth of v
         for i in range(18       ,							-1       ,							-1		):
                if level[u] - (1 << i) >= level[v]:
                       _A   : Tuple       					=				parent[i][u]
      # at the same depth if u==v that mean lca is found
         if u == v:
                return u
         # moving both nodes upwards till lca in found
         for i in range(18       ,							-1       ,							-1		):
                if parent[i][u] not in [0, parent[i][v]]:
                       _A					,    _A   : List[Any]       					=				parent[i][u], parent[i][v]
      # returning longest common ancestor of u,v
         return parent[0][u]
  def 							_UpperCAmelCase       (UpperCamelCase__  :						list[int]       ,							UpperCamelCase__  :						list[list[int]]       ,							UpperCamelCase__  :						int       ,							UpperCamelCase__  :						dict[int, list[int]]       ,							UpperCamelCase__  :						int = 1       ,							):
         _A   : Optional[Any]       					=				0
         _A   : Queue[int]       					=				Queue(maxsize=UpperCamelCase__		)
         q.put(UpperCamelCase__		)
         while q.qsize() != 0:
                _A   : Tuple       					=				q.get()
                for v in graph[u]:
                       if level[v] == -1:
                              _A   : List[str]       					=				level[u] + 1
                              q.put(UpperCamelCase__		)
                              _A   : Optional[Any]       					=				u
         return level, parent
  def 							_UpperCAmelCase       ():
         _A   : Tuple       					=				13
         # initializing with 0
         _A   : Optional[Any]       					=				[[0 for _ in range(max_node + 10		)] for _ in range(20		)]
         # initializing with -1 which means every node is unvisited
         _A   : Any       					=				[-1 for _ in range(max_node + 10		)]
         _A   : dict[int, list[int]]       					=				{
             1: [2, 3, 4],
             2: [5],
             3: [6, 7],
             4: [8],
             5: [9, 10],
             6: [11],
             7: [],
             8: [12, 13],
             9: [],
             10: [],
             11: [],
             12: [],
             13: [],
         }
         _A					,    _A   : Optional[int]       					=				breadth_first_search(UpperCamelCase__       ,							UpperCamelCase__       ,							UpperCamelCase__       ,							UpperCamelCase__       ,							1		)
         _A   : Dict       					=				create_sparse(UpperCamelCase__       ,							UpperCamelCase__		)
         print("LCA of node 1 and 3 is: "       ,							lowest_common_ancestor(1       ,							3       ,							UpperCamelCase__       ,							UpperCamelCase__		)		)
         print("LCA of node 5 and 6 is: "       ,							lowest_common_ancestor(5       ,							6       ,							UpperCamelCase__       ,							UpperCamelCase__		)		)
         print("LCA of node 7 and 11 is: "       ,							lowest_common_ancestor(7       ,							11       ,							UpperCamelCase__       ,							UpperCamelCase__		)		)
         print("LCA of node 6 and 7 is: "       ,							lowest_common_ancestor(6       ,							7       ,							UpperCamelCase__       ,							UpperCamelCase__		)		)
         print("LCA of node 4 and 12 is: "       ,							lowest_common_ancestor(4       ,							12       ,							UpperCamelCase__       ,							UpperCamelCase__		)		)
         print("LCA of node 8 and 8 is: "       ,							lowest_common_ancestor(8       ,							8       ,							UpperCamelCase__       ,							UpperCamelCase__		)		)
  
  
  if __name__ == "__main__":
      main()
  
style_context: 
  
  
  import unittest
  
  import numpy as np
  
  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 MobileNetVaImageProcessor
  
  
  
  
  
  
  
  class   lowerCAmelCase__ (       unittest.TestCase):
  
  
  
  
       '''simple docstring'''
  
  
       def __init__(		self				,		__lowerCamelCase				,		__lowerCamelCase=7				,		__lowerCamelCase=3				,		__lowerCamelCase=1_8				,		__lowerCamelCase=3_0				,		__lowerCamelCase=4_0_0				,		__lowerCamelCase=True				,		__lowerCamelCase=None				,		__lowerCamelCase=True				,		__lowerCamelCase=None				,		)    ->       Tuple:
              _A   : int       					=				size if size is not None else {"shortest_edge": 2_0}
              _A   : Tuple       					=				crop_size if crop_size is not None else {"height": 1_8, "width": 1_8}
              _A   : str       					=				parent
              _A   : Any       					=				batch_size
              _A   : Dict       					=				num_channels
              _A   : int       					=				image_size
              _A   : Union[str, Any]       					=				min_resolution
              _A   : Tuple       					=				max_resolution
              _A   : Any       					=				do_resize
              _A   : Optional[int]       					=				size
              _A   : Tuple       					=				do_center_crop
              _A   : List[str]       					=				crop_size
  
  
       def 				_lowerCamelCase				(		self)    ->       str:
              return {
                  "do_resize": self.do_resize,
                  "size": self.size,
                  "do_center_crop": self.do_center_crop,
                  "crop_size": self.crop_size,
              }
  
  
  
  
  
  
  
  @require_torch
  @require_vision
  class   lowerCAmelCase__ (       a  ,					unittest.TestCase):
  
  
  
  
       '''simple docstring'''
       __SCREAMING_SNAKE_CASE						    =				MobileNetVaImageProcessor if is_vision_available() else None
  
  
       def 				_lowerCamelCase				(		self)    ->       Any:
              _A   : Dict       					=				MobileNetVaImageProcessingTester(self)
  
  
       @property
       def 				_lowerCamelCase				(		self)    ->       Dict:
              return self.image_processor_tester.prepare_image_processor_dict()
  
  
       def 				_lowerCamelCase				(		self)    ->       Tuple:
              _A   : List[Any]       					=				self.image_processing_class(**self.image_processor_dict)
              self.assertTrue(hasattr(__lowerCamelCase				,		"do_resize"))
              self.assertTrue(hasattr(__lowerCamelCase				,		"size"))
              self.assertTrue(hasattr(__lowerCamelCase				,		"do_center_crop"))
              self.assertTrue(hasattr(__lowerCamelCase				,		"center_crop"))
  
  
       def 				_lowerCamelCase				(		self)    ->       Union[str, Any]:
              _A   : int       					=				self.image_processing_class.from_dict(self.image_processor_dict)
              self.assertEqual(image_processor.size				,		{"shortest_edge": 2_0})
              self.assertEqual(image_processor.crop_size				,		{"height": 1_8, "width": 1_8})
  
              _A   : Any       					=				self.image_processing_class.from_dict(self.image_processor_dict				,		size=4_2				,		crop_size=8_4)
              self.assertEqual(image_processor.size				,		{"shortest_edge": 4_2})
              self.assertEqual(image_processor.crop_size				,		{"height": 8_4, "width": 8_4})
  
  
       def 				_lowerCamelCase				(		self)    ->       Union[str, Any]:
              pass
  
  
       def 				_lowerCamelCase				(		self)    ->       List[Any]:
              # Initialize image_processing
              _A   : Optional[int]       					=				self.image_processing_class(**self.image_processor_dict)
              # create random PIL images
              _A   : List[Any]       					=				prepare_image_inputs(self.image_processor_tester				,		equal_resolution=__lowerCamelCase)
              for image in image_inputs:
                     self.assertIsInstance(__lowerCamelCase				,		Image.Image)
  
              # Test not batched input
              _A   : str       					=				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.crop_size["height"],
                      self.image_processor_tester.crop_size["width"],
                  )				,		)
  
              # Test batched
              _A   : Dict       					=				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.crop_size["height"],
                      self.image_processor_tester.crop_size["width"],
                  )				,		)
  
  
       def 				_lowerCamelCase				(		self)    ->       str:
              # Initialize image_processing
              _A   : List[Any]       					=				self.image_processing_class(**self.image_processor_dict)
              # create random numpy tensors
              _A   : int       					=				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
              _A   : 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.crop_size["height"],
                      self.image_processor_tester.crop_size["width"],
                  )				,		)
  
              # Test batched
              _A   : 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.crop_size["height"],
                      self.image_processor_tester.crop_size["width"],
                  )				,		)
  
  
       def 				_lowerCamelCase				(		self)    ->       Tuple:
              # Initialize image_processing
              _A   : str       					=				self.image_processing_class(**self.image_processor_dict)
              # create random PyTorch tensors
              _A   : List[str]       					=				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
              _A   : str       					=				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.crop_size["height"],
                      self.image_processor_tester.crop_size["width"],
                  )				,		)
  
              # Test batched
              _A   : 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.crop_size["height"],
                      self.image_processor_tester.crop_size["width"],
                  )				,		)
  