code: def encode_yaml(val, default_flow_style=False, strict=False):
      """Returns val encoded as YAML.
  
      Uses PyYAML `safe_dump` to serialize `val`. `default_flow_style`
      is passed through to `safe_dump`.
  
      `strict` patches PyYAML to comply with the YAML standard code for
      single characters 'y' and 'n', which need to be quote to retain
      their string type as strict YAML. This is for compatibility
      outside PyYAML.
      """
      with StrictPatch(strict):
          encoded = yaml.safe_dump(
              val,
              default_flow_style=default_flow_style,
              indent=2,
          )
      return _strip_encoded_yaml(encoded)
  
file_path: guildai/guild/yaml_util.py
imports: import os
  import re
  import yaml
label_desc: Use image node_id 1 for calling a global function with example usage: encode_yaml(val, default_flow_style, strict) and returns: _strip_encoded_yaml