code: def from_dict(cls, logical_id, deployment_preference_dict):
          
          enabled = deployment_preference_dict.get('Enabled', True)
          if not enabled:
              return DeploymentPreference(None, None, None, None, False, None)
  
          if 'Type' not in deployment_preference_dict:
              raise InvalidResourceException(logical_id, "'DeploymentPreference' is missing required Property 'Type'")
  
          deployment_type = deployment_preference_dict['Type']
          hooks = deployment_preference_dict.get('Hooks', dict())
          if not isinstance(hooks, dict):
              raise InvalidResourceException(logical_id,
                                             "'Hooks' property of 'DeploymentPreference' must be a dictionary")
  
          pre_traffic_hook = hooks.get('PreTraffic', None)
          post_traffic_hook = hooks.get('PostTraffic', None)
          alarms = deployment_preference_dict.get('Alarms', None)
          role = deployment_preference_dict.get('Role', None)
          return DeploymentPreference(deployment_type, pre_traffic_hook, post_traffic_hook, alarms, enabled, role)
docs: :param logical_id: the logical_id of the resource that owns this deployment preference
          :param deployment_preference_dict: the dict object taken from the SAM template
          :return: