code: def serialize(obj, **options):
      '''
      Serialize Python data to YAML.
  
      :param obj: the data structure to serialize
      :param options: options given to lower yaml module.
      '''
  
      options.setdefault('Dumper', Dumper)
      try:
          response = yaml.dump(obj, **options)
          if response.endswith('\n...\n'):
              return response[:-5]
          if response.endswith('\n'):
              return response[:-1]
          return response
      except Exception as error:
          log.exception('Error encountered while serializing')
          raise SerializationError(errorf serialize(obj, **options):
      '''
      Serialize Python data to YAML.
  
      :param obj: the data structure to serialize
      :param options: options given to lower yaml module.
      '''
  
      options.setdefault('Dumper', Dumper)
      try:
          response = yaml.dump(obj, **options)
          if response.endswith('\n...\n'):
              return response[:-5]
          if response.endswith('\n'):
              return response[:-1]
          return response
      except Exception as error:
          log.exception('Error encountered while serializing')
          raise SerializationError(error)
docs: Serialize Python data to YAML.
  
      :param obj: the data structure to serialize
      :param options: options given to lower yaml module.