code: def _ast_assign_to_dict(
      assign, only_self_params=False, lineno=False
  ):  # noqa: PLR0912
      result = {}
  
      if isinstance(assign, ast.AnnAssign):
          name = _get_ast_name(assign.target, only_self_params)
      elif len(assign.targets) == 1:
          name = _get_ast_name(assign.targets[0], only_self_params)
      else:
          raise AttributeError
  
      value: Any
      if isinstance(assign.value, ast.Dict):
          value = {}
          for key, val in zip(assign.value.keys, assign.value.values):
              if lineno:
                  value[ast.literal_eval(key)] = {  # type: ignore[arg-type]
                      "lineno": assign.lineno - 1,
                      "value": ast.literal_eval(val),
                  }
              else:
                  v = ast.literal_eval(val)
                  value[ast.literal_eval(key)] = v  # type: ignore[arg-type]
      elif isinstance(assign.value, ast.List):
          value = [ast.literal_eval(val) for val in assign.value.elts]
      elif isinstance(assign.value, ast.Set):
          values = [ast.literal_eval(val) for val in assign.value.elts]
          value = set(values)
      elif isinstance(assign.value, ast.Tuple):
          values = [ast.literal_eval(val) for val in assign.value.elts]
          value = tuple(values)
      else:
          value = ast.literal_eval(assign.value)
  
      if lineno and not isinstance(assign.value, ast.Dict):
          result[name] = {"lineno": assign.lineno - 1, "value": value}
      else:
          result[name] = value
  
      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 8 for calling a global function with example usage: _ast_assign_to_dict(assign, only__params, lineno) and returns: result