docs: def to_yaml(self, str_or_buffer=None):
          """
          Save a model respresentation to YAML.
  
          Parameters
          ----------
          str_or_buffer : str or file like, optional
              By default a YAML string is returned. If a string is
              given here the YAML will be written to that file.
              If an object with a ``.write`` method is given the
              YAML will be written to that object.
  
          Returns
          -------
          j : str
              YAML is string if `str_or_buffer` is not given.
  
          """
          logger.debug('serializing LCM model {} to YAML'.format(self.name))
          if (not isinstance(self.probability_mode, str) or
                  not isinstance(self.choice_mode, str)):
              raise TypeError(
                  'Cannot serialize model with non-string probability_mode '
                  'or choice_mode attributes.')
          return yamlio.convert_to_yaml(self.to_dict(), str_or_buffer)