code: def _dump(data, stream):
      old_params = data[_PARAMS_KEY]
      new_params = {
          key: value
          for key, value in data.items()
          if key not in [_PARAMS_KEY, _PARAMS_TEXT_KEY]
      }
      old_lines = data[_PARAMS_TEXT_KEY].splitlines(True)
  
      def _update_lines(lines, old_dct, new_dct):
          for key, value in new_dct.items():
              if isinstance(value, dict):
                  lines = _update_lines(lines, old_dct[key], value)
              elif value != old_dct[key]["value"]:
                  lineno = old_dct[key]["lineno"]
                  lines[lineno] = lines[lineno].replace(
                      f" = {old_dct[key]['value']}", f" = {value}"
                  )
              else:
                  continue
          return lines
  
      new_lines = _update_lines(old_lines, old_params, new_params)
      new_text = "".join(new_lines)
  
      try:
          ast.parse(new_text)
      except SyntaxError:
          raise PythonFileCorruptedError(  # noqa: B904
              stream.name,
              "Python file structure is corrupted after update params",
          )
  
      stream.write(new_text)
      stream.close()
  
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 4 for calling a global function with example usage: _dump(data, stream) and returns: lines