code: def _ast_tree_to_dict(tree, only_self_params=False, lineno=False):
      """Parses ast trees to dict.
  
      :param tree: ast.Tree
      :param only_self_params: get only self params from class __init__ function
      :param lineno: add params line number (needed for update)
      :return:
      """
      result = {}
      for _body in tree.body:
          try:
              if isinstance(_body, (ast.Assign, ast.AnnAssign)):
                  result.update(
                      _ast_assign_to_dict(
                          _body, only_self_params, lineno
                      )
                  )
              elif isinstance(_body, ast.ClassDef):
                  result.update(
                      {
                          _body.name: _ast_tree_to_dict(
                              _body, lineno=lineno
                          )
                      }
                  )
              elif (
                  isinstance(_body, ast.FunctionDef)
                  and _body.name == "__init__"
              ):
                  result.update(
                      _ast_tree_to_dict(
                          _body, only_self_params=True, lineno=lineno
                      )
                  )
          except ValueError:
              continue
          except AttributeError:
              continue
      return result
  
file_path: dvc/dvc/utils/serialize/_py.py
imports: import ast
  from contextlib import contextmanager
  from typing import Any
  from funcy import reraise
  from ._common import ParseError, _dump_data, _load_data, _modify_data
label_desc: Use image node_id 7 for calling a global function with example usage: _ast_tree_to_dict(tree, only__params, lineno) and returns: result