code: def yaml_to_dict(yaml_str=None, str_or_buffer=None, ordered=False):
      
      if not yaml_str and not str_or_buffer:
          raise ValueError('One of yaml_str or str_or_buffer is required.')
  
      # determine which load method to use
      if ordered:
          loader = __ordered_load
      else:
          loader = yaml.load
  
      if yaml_str:
          d = loader(yaml_str)
      elif isinstance(str_or_buffer, str):
          with open(str_or_buffer) as f:
              d = loader(f)
      else:
          d = loader(str_or_buffer)
  
      return d
docs: Load YAML from a string, file, or buffer (an object with a .read method).
      Parameters are mutually exclusive.
  
      Parameters
      ----------
      yaml_str : str, optional
          A string of YAML.
      str_or_buffer : str or file like, optional
          File name or buffer from which to load YAML.
      ordered: bool, optional, default False
          If True, an OrderedDict is returned.
  
      Returns
      -------
      dict
          Conversion from YAML.