code: def persistent_menu(menu):
      
      if len(menu) > 3:
          raise Invalid('menu should not exceed 3 call to actions')
  
      if any(len(item['call_to_actions']) > 5 for item in menu if item['type'] == 'nested'):
          raise Invalid('call_to_actions is limited to 5 for sub-levels')
  
      for item in menu:
          if len(item['title']) > 30:
              raise Invalid('menu item title should not exceed 30 characters')
  
          if item['type'] == 'postback' and len(item['payload']) > 1000:
              raise Invalid('menu item payload should not exceed 1000 characters')
docs: more: https://developers.facebook.com/docs/messenger-platform/thread-settings/persistent-menu
  
      :param menu:
      :return: