<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def from_yaml(cls, yaml_path, filename=None):
 """Split a dictionary into parameters controllers parts blocks defines Args: yaml_path (str):
 File path to YAML file, or a file in the same dir filename (str):
 If give, use this filename as the last element in the yaml_path (so yaml_path can be __file__) Returns: tuple: (sections, yamlname, docstring) where sections is a list of created sections """

        if filename:
            # different filename to support passing __file__
            yaml_path = os.path.join(os.path.dirname(yaml_path), filename)
        assert yaml_path.endswith(".yaml"), \
            "Expected a/path/to/<yamlname>.yaml, got %r" % yaml_path
        yamlname = os.path.basename(yaml_path)[:-5]
        log.debug("Parsing %s", yaml_path)
        with open(yaml_path) as f:
            text = f.read()
        # First separate them into their relevant sections
        ds = yaml.load(text, Loader=yaml.RoundTripLoader)
        docstring = None
        sections = []
        for d in ds:
            assert len(d) == 1, \
                "Expected section length 1, got %d" % len(d)
            lineno = d._yaml_line_col.line + 1
            name = list(d)[0]
            sections.append(cls(
                yaml_path, lineno, name, d[name]))
            if name == "builtin.defines.docstring":
                docstring = d[name]["value"]

        return sections, yamlname, docstring