code: def test_update(ast_transformer, pasta_parse, pasta_dump, json_dump):
      notebook_template = """{
          "cells": [
           {
            "cell_type": "code",
            "execution_count": 1,
            "metadata": {},
            "outputs": [],
            "source": [
             "!echo ignore this"
            ]
           },
           {
            "cell_type": "code",
            "execution_count": 2,
            "metadata": {},
            "outputs": [],
            "source": [
             "%%%%bash\\n",
             "echo ignore this too"
            ]
           },
           {
            "cell_type": "code",
            "execution_count": 3,
            "metadata": {},
            "outputs": [],
            "source": [
             "%%cd\\n",
             "echo ignore this too"
            ]
           },
           {
            "cell_type": "code",
            "execution_count": 4,
            "metadata": {},
            "outputs": [],
            "source": [
             "# code to be modified\\n",
             "%s"
            ]
           }
          ],
          "metadata": {
           "kernelspec": {
            "display_name": "Python 3",
            "language": "python",
            "name": "python3"
           },
           "language_info": {
            "codemirror_mode": {
             "name": "ipython",
             "version": 3
            },
            "file_extension": ".py",
            "mimetype": "text/x-python",
            "name": "python",
            "nbconvert_exporter": "python",
            "pygments_lexer": "ipython3",
            "version": "3.6.8"
           }
          },
          "nbformat": 4,
          "nbformat_minor": 2
         }
      """
      input_code = "print('hello, world!')"
      input_notebook = notebook_template % input_code
  
      input_ast = Mock()
      pasta_parse.return_value = input_ast
  
      output_ast = Mock(_fields=[])
      ast_transformer.return_value.visit.return_value = output_ast
      output_code = "print('goodbye')"
      pasta_dump.return_value = "# code to be modified\n{}".format(
          output_code
      )
  
      input_file = "input.py"
      output_file = "output.py"
  
      open_mock = mock_open(read_data=input_notebook)
      with patch("six.moves.builtins.open", open_mock):
          updater = files.JupyterNotebookFileUpdater(
              input_file, output_file
          )
          updater.update()
  
      pasta_parse.assert_called_with(
          "# code to be modified\n{}".format(input_code)
      )
      ast_transformer.return_value.visit.assert_called_with(input_ast)
      pasta_dump.assert_called_with(output_ast)
  
      assert call(input_file) in open_mock.mock_calls
      assert call(output_file, "w") in open_mock.mock_calls
  
      json_dump.assert_called_with(
          json.loads(notebook_template % output_code),
          open_mock(),
          indent=1,
      )
      open_mock().write.assert_called_with("\n")
  
file_path: sagemaker-python-sdk/tests/unit/sagemaker/cli/compatibility/v2/test_file_updaters.py
imports: from __future__ import absolute_import
  import json
  import os
  from mock import call, Mock, mock_open, patch
  from sagemaker.cli.compatibility.v2 import files
label_desc: Use image node_id 5 for calling a global function with example usage: test_update(ast_transformer, pasta_parse, pasta_dump, json_dump) without return types