code: def dump(data, stream=None, **kwds):
      
  
      # Display OrderedDicts correctly
      class OrderedDumper(SafeDumper):
          pass
  
      def _dict_representer(dumper, data):
          return dumper.represent_mapping(
              original_yaml.resolver.BaseResolver.DEFAULT_MAPPING_TAG,
              list(data.items()))
  
      # Display long strings correctly
      def _long_str_representer(dumper, data):
          if data.find("\n") != -1:
              # Drop some uneeded data
              # \t are forbidden in YAML
              data = data.replace("\t", "    ")
              # empty spaces at end of line are always useless in INGInious, and forbidden in YAML
              data = "\n".join([p.rstrip() for p in data.split("\n")])
              return dumper.represent_scalar('tag:yaml.org,2002:str', data, style='|')
          else:
              return dumper.represent_scalar('tag:yaml.org,2002:str', data)
  
      # Default representation for some odd objects
      def _default_representer(dumper, data):
          return _long_str_representer(dumper, str(data))
  
      OrderedDumper.add_representer(str, _long_str_representer)
      OrderedDumper.add_representer(str, _long_str_representer)
      OrderedDumper.add_representer(OrderedDict, _dict_representer)
      OrderedDumper.add_representer(None, _default_representer)
  
      s = original_yaml.dump(data, stream, OrderedDumper, encoding='utf-8', allow_unicode=True, default_flow_style=False, indent=4, **kwds)
  
      if s is not None:
          return s.decode('utf-8')
      else:
          return
docs: Serialize a Python object into a YAML stream.
          If stream is None, return the produced string instead.
          Dict keys are produced in the order in which they appear in OrderedDicts.
  
          Safe version.
  
          If objects are not "conventional" objects, they will be dumped converted to string with the str() function.
          They will then not be recovered when loading with the load() function.