code: 
  
  
  from __future__ import annotations
  
  from collections import defaultdict
  from dataclasses import dataclass
  
  
  
  @dataclass
  class   __lowerCamelCase :
         _lowercase       							=    42
         _lowercase       							=    None
         _lowercase       							=    None
  
  
  
  
  
  
  def 		_A		(		):
  
  
       """simple docstring"""
  
  
       return TreeNode(3				,     TreeNode(9   )				,     TreeNode(20				,     TreeNode(15   )				,     TreeNode(7   )   )   )
  
  
  
  
  
  
  def 		_A		(		_lowercase   ):
  
  
       """simple docstring"""
  
  
       def depth_first_search(
           _lowercase				,     _lowercase				,     _lowercase   ) -> None:
            if not root:
                 return
  
            if depth == len(_lowercase   ):
                 right_view.append(root.val   )
  
            depth_first_search(root.right				,     depth + 1				,     _lowercase   )
            depth_first_search(root.left				,     depth + 1				,     _lowercase   )
  
       __UpperCamelCase   = []
       if not root:
            return right_view
  
       depth_first_search(_lowercase				,     0				,     _lowercase   )
       return right_view
  
  
  
  
  
  
  def 		_A		(		_lowercase   ):
  
  
       """simple docstring"""
  
  
       def depth_first_search(
           _lowercase				,     _lowercase				,     _lowercase   ) -> None:
            if not root:
                 return
  
            if depth == len(_lowercase   ):
                 left_view.append(root.val   )
  
            depth_first_search(root.left				,     depth + 1				,     _lowercase   )
            depth_first_search(root.right				,     depth + 1				,     _lowercase   )
  
       __UpperCamelCase   = []
       if not root:
            return left_view
  
       depth_first_search(_lowercase				,     0				,     _lowercase   )
       return left_view
  
  
  
  
  
  
  def 		_A		(		_lowercase   ):
  
  
       """simple docstring"""
  
  
       def breadth_first_search(_lowercase				,     _lowercase   ) -> None:
            __UpperCamelCase   = [(root, 0)]
            __UpperCamelCase   = defaultdict(_lowercase   )
  
            while queue:
                 __UpperCamelCase   = queue.pop(0   )
                 __UpperCamelCase,						__UpperCamelCase   = first
  
                 lookup[hd].append(node.val   )
  
                 if node.left:
                      queue.append((node.left, hd - 1)   )
                 if node.right:
                      queue.append((node.right, hd + 1)   )
  
            for pair in sorted(lookup.items()				,     key=lambda _lowercase   : each[0]   ):
                 top_view.append(pair[1][0]   )
  
       __UpperCamelCase   = []
       if not root:
            return top_view
  
       breadth_first_search(_lowercase				,     _lowercase   )
       return top_view
  
  
  
  
  
  
  def 		_A		(		_lowercase   ):
  
  
       """simple docstring"""
  
  
       from collections import defaultdict
  
       def breadth_first_search(_lowercase				,     _lowercase   ) -> None:
            __UpperCamelCase   = [(root, 0)]
            __UpperCamelCase   = defaultdict(_lowercase   )
  
            while queue:
                 __UpperCamelCase   = queue.pop(0   )
                 __UpperCamelCase,						__UpperCamelCase   = first
                 lookup[hd].append(node.val   )
  
                 if node.left:
                      queue.append((node.left, hd - 1)   )
                 if node.right:
                      queue.append((node.right, hd + 1)   )
  
            for pair in sorted(lookup.items()				,     key=lambda _lowercase   : each[0]   ):
                 bottom_view.append(pair[1][-1]   )
  
       __UpperCamelCase   = []
       if not root:
            return bottom_view
  
       breadth_first_search(_lowercase				,     _lowercase   )
       return bottom_view
  
  
  if __name__ == "__main__":
      import doctest
  
      doctest.testmod()
  
  
  
style_context: 
  
  
  from ..utils import DummyObject, requires_backends
  
  
  
  class   __lowerCamelCase (metaclass=_a	):
         _lowercase       							=    ["""torch""", """transformers""", """k_diffusion"""]
  
  
  
  
  
  
  
         def __init__( self:   Tuple,*A_:   Union[str, Any],**A_:   Tuple				):
  
  
  
  
  
  
              '''simple docstring'''
  
  
  
  
              requires_backends(self,['torch', 'transformers', 'k_diffusion']				)
  
  
  
  
  
  
  
         @classmethod
         def 		snake_case_  ( cls:   int,*A_:   Optional[Any],**A_:   Tuple				):
  
  
  
  
  
  
              '''simple docstring'''
  
  
  
  
              requires_backends(cls,['torch', 'transformers', 'k_diffusion']				)
  
  
  
  
  
  
  
         @classmethod
         def 		snake_case_  ( cls:   int,*A_:   Tuple,**A_:   Tuple				):
  
  
  
  
  
  
              '''simple docstring'''
  
  
  
  
              requires_backends(cls,['torch', 'transformers', 'k_diffusion']				)
  
  
  