We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
bug: AttributeError: 'NoneType' object has no attribute 'module' when applying the v2 upgrade tool
**Describe the bug**

When applying the `sagemaker-upgrade-v2` automated CLI tool, earlier ast modification leads to an `AttributeError` exception.

**To reproduce**

1. Craft a script that will be modified by a SerDe import renamer
1. Apply the V2 upgrade CLI tool: 

An `AttributeError` exception is raised.

**Expected behavior**

The V2 upgrade CLI would properly upgrade the script.

**Screenshots or logs**

```
❯ cat v1.py
import sagemaker

from sagemaker.predictor import csv_serializer

csv_serializer.__doc___

❯ sagemaker-upgrade-v2 --in-file v1.py --out-file v2.py
Traceback (most recent call last):
  File "~/testvenv/bin/sagemaker-upgrade-v2", line 8, in <module>
    sys.exit(main())
  File "~/testvenv/lib/python3.8/site-packages/sagemaker/cli/compatibility/v2/sagemaker_upgrade_v2.py", line 78, in main
    _update_file(args.in_file, args.out_file)
  File "~/testvenv/lib/python3.8/site-packages/sagemaker/cli/compatibility/v2/sagemaker_upgrade_v2.py", line 50, in _update_file
    updater_cls(input_path=input_file, output_path=output_file).update()
  File "~/testvenv/lib/python3.8/site-packages/sagemaker/cli/compatibility/v2/files.py", line 72, in update
    output = self._update_ast(self._read_input_file())
  File "~/testvenv/lib/python3.8/site-packages/sagemaker/cli/compatibility/v2/files.py", line 86, in _update_ast
    return ASTTransformer().visit(input_ast)
  File "/usr/lib/python3.8/ast.py", line 363, in visit
    return visitor(node)
  File "~/testvenv/lib/python3.8/site-packages/sagemaker/cli/compatibility/v2/ast_transformer.py", line 136, in visit_Module
    self.generic_visit(node)
  File "/usr/lib/python3.8/ast.py", line 439, in generic_visit
    value = self.visit(value)
  File "/usr/lib/python3.8/ast.py", line 363, in visit
    return visitor(node)
  File "~/testvenv/lib/python3.8/site-packages/sagemaker/cli/compatibility/v2/ast_transformer.py", line 155, in visit_ImportFrom
    node = import_checker.check_and_modify_node(node)
  File "~/testvenv/lib/python3.8/site-packages/sagemaker/cli/compatibility/v2/modifiers/modifier.py", line 26, in check_and_modify_node
    if self.node_should_be_modified(node):
  File "~/testvenv/lib/python3.8/site-packages/sagemaker/cli/compatibility/v2/modifiers/image_uris.py", line 115, in node_should_be_modified
    return node.module in GET_IMAGE_URI_NAMESPACES and any(
AttributeError: 'NoneType' object has no attribute 'module'
```

**System information**
A description of your system. Please provide:
- **SageMaker Python SDK version**: 2.4.1
- **Framework name (eg. PyTorch) or algorithm (eg. KMeans)**:
- **Framework version**:
- **Python version**:
- **CPU or GPU**:
- **Custom Docker image (Y/N)**:

**Additional context**

The problem comes from [the ordering](https://github.com/aws/sagemaker-python-sdk/blob/v2.4.1/src/sagemaker/cli/compatibility/v2/ast_transformer.py#L59-L60), which the existing, isolated unit tests do not cover. The earlier renamer modifies the ast, and the later renamer cannot handle this situation:

```
 59     modifiers.serde.SerdeImportFromPredictorRenamer(),
 60     modifiers.image_uris.ImageURIRetrieveImportFromRenamer(),
```

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `src/sagemaker/cli/compatibility/v2/modifiers/image_uris.py`
Content:
```
1 # Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
2 #
3 # Licensed under the Apache License, Version 2.0 (the "License"). You
4 # may not use this file except in compliance with the License. A copy of
5 # the License is located at
6 #
7 #     http://aws.amazon.com/apache2.0/
8 #
9 # or in the "license" file accompanying this file. This file is
10 # distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
11 # ANY KIND, either express or implied. See the License for the specific
12 # language governing permissions and limitations under the License.
13 """Classes to modify image uri retrieve methods for Python SDK v2.0 and later."""
14 from __future__ import absolute_import
15 
16 import ast
17 
18 from sagemaker.cli.compatibility.v2.modifiers import matching
19 from sagemaker.cli.compatibility.v2.modifiers.modifier import Modifier
20 
21 GET_IMAGE_URI_NAME = "get_image_uri"
22 GET_IMAGE_URI_NAMESPACES = (
23     "sagemaker",
24     "sagemaker.amazon_estimator",
25     "sagemaker.amazon.amazon_estimator",
26     "amazon_estimator",
27     "amazon.amazon_estimator",
28 )
29 
30 
31 class ImageURIRetrieveRefactor(Modifier):
32     """A class to refactor *get_image_uri() method."""
33 
34     def node_should_be_modified(self, node):
35         """Checks if the ``ast.Call`` node calls a function of interest.
36 
37         This looks for the following calls:
38 
39         - ``sagemaker.get_image_uri``
40         - ``sagemaker.amazon_estimator.get_image_uri``
41         - ``get_image_uri``
42 
43         Args:
44             node (ast.Call): a node that represents a function call. For more,
45                 see https://docs.python.org/3/library/ast.html#abstract-grammar.
46 
47         Returns:
48             bool: If the ``ast.Call`` instantiates a class of interest.
49         """
50         return matching.matches_name_or_namespaces(
51             node, GET_IMAGE_URI_NAME, GET_IMAGE_URI_NAMESPACES
52         )
53 
54     def modify_node(self, node):
55         """Modifies the ``ast.Call`` node to call ``image_uris.retrieve`` instead.
56         And switch the first two parameters from (region, repo) to (framework, region)
57 
58         Args:
59             node (ast.Call): a node that represents a *image_uris.retrieve call.
60         """
61         original_args = [None] * 3
62         for kw in node.keywords:
63             if kw.arg == "repo_name":
64                 original_args[0] = ast.Str(kw.value.s)
65             elif kw.arg == "repo_region":
66                 original_args[1] = ast.Str(kw.value.s)
67             elif kw.arg == "repo_version":
68                 original_args[2] = ast.Str(kw.value.s)
69 
70         if len(node.args) > 0:
71             original_args[1] = ast.Str(node.args[0].s)
72         if len(node.args) > 1:
73             original_args[0] = ast.Str(node.args[1].s)
74         if len(node.args) > 2:
75             original_args[2] = ast.Str(node.args[2].s)
76 
77         args = []
78         for arg in original_args:
79             if arg:
80                 args.append(arg)
81 
82         func = node.func
83         has_sagemaker = False
84         while hasattr(func, "value"):
85             if hasattr(func.value, "id") and func.value.id == "sagemaker":
86                 has_sagemaker = True
87                 break
88             func = func.value
89 
90         if has_sagemaker:
91             node.func = ast.Attribute(
92                 value=ast.Attribute(attr="image_uris", value=ast.Name(id="sagemaker")),
93                 attr="retrieve",
94             )
95         else:
96             node.func = ast.Attribute(value=ast.Name(id="image_uris"), attr="retrieve")
97         node.args = args
98         node.keywords = []
99         return node
100 
101 
102 class ImageURIRetrieveImportFromRenamer(Modifier):
103     """A class to update import statements of ``get_image_uri``."""
104 
105     def node_should_be_modified(self, node):
106         """Checks if the import statement imports ``get_image_uri`` from the correct module.
107 
108         Args:
109             node (ast.ImportFrom): a node that represents a ``from ... import ... `` statement.
110                 For more, see https://docs.python.org/3/library/ast.html#abstract-grammar.
111 
112         Returns:
113             bool: If the import statement imports ``get_image_uri`` from the correct module.
114         """
115         return node.module in GET_IMAGE_URI_NAMESPACES and any(
116             name.name == GET_IMAGE_URI_NAME for name in node.names
117         )
118 
119     def modify_node(self, node):
120         """Changes the ``ast.ImportFrom`` node's name from ``get_image_uri`` to ``image_uris``.
121 
122         Args:
123             node (ast.ImportFrom): a node that represents a ``from ... import ... `` statement.
124                 For more, see https://docs.python.org/3/library/ast.html#abstract-grammar.
125 
126         Returns:
127             ast.AST: the original node, which has been potentially modified.
128         """
129         for name in node.names:
130             if name.name == GET_IMAGE_URI_NAME:
131                 name.name = "image_uris"
132             if node.module in GET_IMAGE_URI_NAMESPACES:
133                 node.module = "sagemaker"
134         return node
135
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/src/sagemaker/cli/compatibility/v2/modifiers/image_uris.py b/src/sagemaker/cli/compatibility/v2/modifiers/image_uris.py
--- a/src/sagemaker/cli/compatibility/v2/modifiers/image_uris.py
+++ b/src/sagemaker/cli/compatibility/v2/modifiers/image_uris.py
@@ -112,8 +112,10 @@
         Returns:
             bool: If the import statement imports ``get_image_uri`` from the correct module.
         """
-        return node.module in GET_IMAGE_URI_NAMESPACES and any(
-            name.name == GET_IMAGE_URI_NAME for name in node.names
+        return (
+            node is not None
+            and node.module in GET_IMAGE_URI_NAMESPACES
+            and any(name.name == GET_IMAGE_URI_NAME for name in node.names)
         )
 
     def modify_node(self, node):

{"golden_diff": "diff --git a/src/sagemaker/cli/compatibility/v2/modifiers/image_uris.py b/src/sagemaker/cli/compatibility/v2/modifiers/image_uris.py\n--- a/src/sagemaker/cli/compatibility/v2/modifiers/image_uris.py\n+++ b/src/sagemaker/cli/compatibility/v2/modifiers/image_uris.py\n@@ -112,8 +112,10 @@\n         Returns:\n             bool: If the import statement imports ``get_image_uri`` from the correct module.\n         \"\"\"\n-        return node.module in GET_IMAGE_URI_NAMESPACES and any(\n-            name.name == GET_IMAGE_URI_NAME for name in node.names\n+        return (\n+            node is not None\n+            and node.module in GET_IMAGE_URI_NAMESPACES\n+            and any(name.name == GET_IMAGE_URI_NAME for name in node.names)\n         )\n \n     def modify_node(self, node):\n", "issue": "bug: AttributeError: 'NoneType' object has no attribute 'module' when applying the v2 upgrade tool\n**Describe the bug**\r\n\r\nWhen applying the `sagemaker-upgrade-v2` automated CLI tool, earlier ast modification leads to an `AttributeError` exception.\r\n\r\n**To reproduce**\r\n\r\n1. Craft a script that will be modified by a SerDe import renamer\r\n1. Apply the V2 upgrade CLI tool: \r\n\r\nAn `AttributeError` exception is raised.\r\n\r\n**Expected behavior**\r\n\r\nThe V2 upgrade CLI would properly upgrade the script.\r\n\r\n**Screenshots or logs**\r\n\r\n```\r\n\u276f cat v1.py\r\nimport sagemaker\r\n\r\nfrom sagemaker.predictor import csv_serializer\r\n\r\ncsv_serializer.__doc___\r\n\r\n\u276f sagemaker-upgrade-v2 --in-file v1.py --out-file v2.py\r\nTraceback (most recent call last):\r\n  File \"~/testvenv/bin/sagemaker-upgrade-v2\", line 8, in <module>\r\n    sys.exit(main())\r\n  File \"~/testvenv/lib/python3.8/site-packages/sagemaker/cli/compatibility/v2/sagemaker_upgrade_v2.py\", line 78, in main\r\n    _update_file(args.in_file, args.out_file)\r\n  File \"~/testvenv/lib/python3.8/site-packages/sagemaker/cli/compatibility/v2/sagemaker_upgrade_v2.py\", line 50, in _update_file\r\n    updater_cls(input_path=input_file, output_path=output_file).update()\r\n  File \"~/testvenv/lib/python3.8/site-packages/sagemaker/cli/compatibility/v2/files.py\", line 72, in update\r\n    output = self._update_ast(self._read_input_file())\r\n  File \"~/testvenv/lib/python3.8/site-packages/sagemaker/cli/compatibility/v2/files.py\", line 86, in _update_ast\r\n    return ASTTransformer().visit(input_ast)\r\n  File \"/usr/lib/python3.8/ast.py\", line 363, in visit\r\n    return visitor(node)\r\n  File \"~/testvenv/lib/python3.8/site-packages/sagemaker/cli/compatibility/v2/ast_transformer.py\", line 136, in visit_Module\r\n    self.generic_visit(node)\r\n  File \"/usr/lib/python3.8/ast.py\", line 439, in generic_visit\r\n    value = self.visit(value)\r\n  File \"/usr/lib/python3.8/ast.py\", line 363, in visit\r\n    return visitor(node)\r\n  File \"~/testvenv/lib/python3.8/site-packages/sagemaker/cli/compatibility/v2/ast_transformer.py\", line 155, in visit_ImportFrom\r\n    node = import_checker.check_and_modify_node(node)\r\n  File \"~/testvenv/lib/python3.8/site-packages/sagemaker/cli/compatibility/v2/modifiers/modifier.py\", line 26, in check_and_modify_node\r\n    if self.node_should_be_modified(node):\r\n  File \"~/testvenv/lib/python3.8/site-packages/sagemaker/cli/compatibility/v2/modifiers/image_uris.py\", line 115, in node_should_be_modified\r\n    return node.module in GET_IMAGE_URI_NAMESPACES and any(\r\nAttributeError: 'NoneType' object has no attribute 'module'\r\n```\r\n\r\n**System information**\r\nA description of your system. Please provide:\r\n- **SageMaker Python SDK version**: 2.4.1\r\n- **Framework name (eg. PyTorch) or algorithm (eg. KMeans)**:\r\n- **Framework version**:\r\n- **Python version**:\r\n- **CPU or GPU**:\r\n- **Custom Docker image (Y/N)**:\r\n\r\n**Additional context**\r\n\r\nThe problem comes from [the ordering](https://github.com/aws/sagemaker-python-sdk/blob/v2.4.1/src/sagemaker/cli/compatibility/v2/ast_transformer.py#L59-L60), which the existing, isolated unit tests do not cover. The earlier renamer modifies the ast, and the later renamer cannot handle this situation:\r\n\r\n```\r\n 59     modifiers.serde.SerdeImportFromPredictorRenamer(),\r\n 60     modifiers.image_uris.ImageURIRetrieveImportFromRenamer(),\r\n```\n", "before_files": [{"content": "# Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\"). You\n# may not use this file except in compliance with the License. A copy of\n# the License is located at\n#\n#     http://aws.amazon.com/apache2.0/\n#\n# or in the \"license\" file accompanying this file. This file is\n# distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF\n# ANY KIND, either express or implied. See the License for the specific\n# language governing permissions and limitations under the License.\n\"\"\"Classes to modify image uri retrieve methods for Python SDK v2.0 and later.\"\"\"\nfrom __future__ import absolute_import\n\nimport ast\n\nfrom sagemaker.cli.compatibility.v2.modifiers import matching\nfrom sagemaker.cli.compatibility.v2.modifiers.modifier import Modifier\n\nGET_IMAGE_URI_NAME = \"get_image_uri\"\nGET_IMAGE_URI_NAMESPACES = (\n    \"sagemaker\",\n    \"sagemaker.amazon_estimator\",\n    \"sagemaker.amazon.amazon_estimator\",\n    \"amazon_estimator\",\n    \"amazon.amazon_estimator\",\n)\n\n\nclass ImageURIRetrieveRefactor(Modifier):\n    \"\"\"A class to refactor *get_image_uri() method.\"\"\"\n\n    def node_should_be_modified(self, node):\n        \"\"\"Checks if the ``ast.Call`` node calls a function of interest.\n\n        This looks for the following calls:\n\n        - ``sagemaker.get_image_uri``\n        - ``sagemaker.amazon_estimator.get_image_uri``\n        - ``get_image_uri``\n\n        Args:\n            node (ast.Call): a node that represents a function call. For more,\n                see https://docs.python.org/3/library/ast.html#abstract-grammar.\n\n        Returns:\n            bool: If the ``ast.Call`` instantiates a class of interest.\n        \"\"\"\n        return matching.matches_name_or_namespaces(\n            node, GET_IMAGE_URI_NAME, GET_IMAGE_URI_NAMESPACES\n        )\n\n    def modify_node(self, node):\n        \"\"\"Modifies the ``ast.Call`` node to call ``image_uris.retrieve`` instead.\n        And switch the first two parameters from (region, repo) to (framework, region)\n\n        Args:\n            node (ast.Call): a node that represents a *image_uris.retrieve call.\n        \"\"\"\n        original_args = [None] * 3\n        for kw in node.keywords:\n            if kw.arg == \"repo_name\":\n                original_args[0] = ast.Str(kw.value.s)\n            elif kw.arg == \"repo_region\":\n                original_args[1] = ast.Str(kw.value.s)\n            elif kw.arg == \"repo_version\":\n                original_args[2] = ast.Str(kw.value.s)\n\n        if len(node.args) > 0:\n            original_args[1] = ast.Str(node.args[0].s)\n        if len(node.args) > 1:\n            original_args[0] = ast.Str(node.args[1].s)\n        if len(node.args) > 2:\n            original_args[2] = ast.Str(node.args[2].s)\n\n        args = []\n        for arg in original_args:\n            if arg:\n                args.append(arg)\n\n        func = node.func\n        has_sagemaker = False\n        while hasattr(func, \"value\"):\n            if hasattr(func.value, \"id\") and func.value.id == \"sagemaker\":\n                has_sagemaker = True\n                break\n            func = func.value\n\n        if has_sagemaker:\n            node.func = ast.Attribute(\n                value=ast.Attribute(attr=\"image_uris\", value=ast.Name(id=\"sagemaker\")),\n                attr=\"retrieve\",\n            )\n        else:\n            node.func = ast.Attribute(value=ast.Name(id=\"image_uris\"), attr=\"retrieve\")\n        node.args = args\n        node.keywords = []\n        return node\n\n\nclass ImageURIRetrieveImportFromRenamer(Modifier):\n    \"\"\"A class to update import statements of ``get_image_uri``.\"\"\"\n\n    def node_should_be_modified(self, node):\n        \"\"\"Checks if the import statement imports ``get_image_uri`` from the correct module.\n\n        Args:\n            node (ast.ImportFrom): a node that represents a ``from ... import ... `` statement.\n                For more, see https://docs.python.org/3/library/ast.html#abstract-grammar.\n\n        Returns:\n            bool: If the import statement imports ``get_image_uri`` from the correct module.\n        \"\"\"\n        return node.module in GET_IMAGE_URI_NAMESPACES and any(\n            name.name == GET_IMAGE_URI_NAME for name in node.names\n        )\n\n    def modify_node(self, node):\n        \"\"\"Changes the ``ast.ImportFrom`` node's name from ``get_image_uri`` to ``image_uris``.\n\n        Args:\n            node (ast.ImportFrom): a node that represents a ``from ... import ... `` statement.\n                For more, see https://docs.python.org/3/library/ast.html#abstract-grammar.\n\n        Returns:\n            ast.AST: the original node, which has been potentially modified.\n        \"\"\"\n        for name in node.names:\n            if name.name == GET_IMAGE_URI_NAME:\n                name.name = \"image_uris\"\n            if node.module in GET_IMAGE_URI_NAMESPACES:\n                node.module = \"sagemaker\"\n        return node\n", "path": "src/sagemaker/cli/compatibility/v2/modifiers/image_uris.py"}], "after_files": [{"content": "# Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\"). You\n# may not use this file except in compliance with the License. A copy of\n# the License is located at\n#\n#     http://aws.amazon.com/apache2.0/\n#\n# or in the \"license\" file accompanying this file. This file is\n# distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF\n# ANY KIND, either express or implied. See the License for the specific\n# language governing permissions and limitations under the License.\n\"\"\"Classes to modify image uri retrieve methods for Python SDK v2.0 and later.\"\"\"\nfrom __future__ import absolute_import\n\nimport ast\n\nfrom sagemaker.cli.compatibility.v2.modifiers import matching\nfrom sagemaker.cli.compatibility.v2.modifiers.modifier import Modifier\n\nGET_IMAGE_URI_NAME = \"get_image_uri\"\nGET_IMAGE_URI_NAMESPACES = (\n    \"sagemaker\",\n    \"sagemaker.amazon_estimator\",\n    \"sagemaker.amazon.amazon_estimator\",\n    \"amazon_estimator\",\n    \"amazon.amazon_estimator\",\n)\n\n\nclass ImageURIRetrieveRefactor(Modifier):\n    \"\"\"A class to refactor *get_image_uri() method.\"\"\"\n\n    def node_should_be_modified(self, node):\n        \"\"\"Checks if the ``ast.Call`` node calls a function of interest.\n\n        This looks for the following calls:\n\n        - ``sagemaker.get_image_uri``\n        - ``sagemaker.amazon_estimator.get_image_uri``\n        - ``get_image_uri``\n\n        Args:\n            node (ast.Call): a node that represents a function call. For more,\n                see https://docs.python.org/3/library/ast.html#abstract-grammar.\n\n        Returns:\n            bool: If the ``ast.Call`` instantiates a class of interest.\n        \"\"\"\n        return matching.matches_name_or_namespaces(\n            node, GET_IMAGE_URI_NAME, GET_IMAGE_URI_NAMESPACES\n        )\n\n    def modify_node(self, node):\n        \"\"\"Modifies the ``ast.Call`` node to call ``image_uris.retrieve`` instead.\n        And switch the first two parameters from (region, repo) to (framework, region)\n\n        Args:\n            node (ast.Call): a node that represents a *image_uris.retrieve call.\n        \"\"\"\n        original_args = [None] * 3\n        for kw in node.keywords:\n            if kw.arg == \"repo_name\":\n                original_args[0] = ast.Str(kw.value.s)\n            elif kw.arg == \"repo_region\":\n                original_args[1] = ast.Str(kw.value.s)\n            elif kw.arg == \"repo_version\":\n                original_args[2] = ast.Str(kw.value.s)\n\n        if len(node.args) > 0:\n            original_args[1] = ast.Str(node.args[0].s)\n        if len(node.args) > 1:\n            original_args[0] = ast.Str(node.args[1].s)\n        if len(node.args) > 2:\n            original_args[2] = ast.Str(node.args[2].s)\n\n        args = []\n        for arg in original_args:\n            if arg:\n                args.append(arg)\n\n        func = node.func\n        has_sagemaker = False\n        while hasattr(func, \"value\"):\n            if hasattr(func.value, \"id\") and func.value.id == \"sagemaker\":\n                has_sagemaker = True\n                break\n            func = func.value\n\n        if has_sagemaker:\n            node.func = ast.Attribute(\n                value=ast.Attribute(attr=\"image_uris\", value=ast.Name(id=\"sagemaker\")),\n                attr=\"retrieve\",\n            )\n        else:\n            node.func = ast.Attribute(value=ast.Name(id=\"image_uris\"), attr=\"retrieve\")\n        node.args = args\n        node.keywords = []\n        return node\n\n\nclass ImageURIRetrieveImportFromRenamer(Modifier):\n    \"\"\"A class to update import statements of ``get_image_uri``.\"\"\"\n\n    def node_should_be_modified(self, node):\n        \"\"\"Checks if the import statement imports ``get_image_uri`` from the correct module.\n\n        Args:\n            node (ast.ImportFrom): a node that represents a ``from ... import ... `` statement.\n                For more, see https://docs.python.org/3/library/ast.html#abstract-grammar.\n\n        Returns:\n            bool: If the import statement imports ``get_image_uri`` from the correct module.\n        \"\"\"\n        return (\n            node is not None\n            and node.module in GET_IMAGE_URI_NAMESPACES\n            and any(name.name == GET_IMAGE_URI_NAME for name in node.names)\n        )\n\n    def modify_node(self, node):\n        \"\"\"Changes the ``ast.ImportFrom`` node's name from ``get_image_uri`` to ``image_uris``.\n\n        Args:\n            node (ast.ImportFrom): a node that represents a ``from ... import ... `` statement.\n                For more, see https://docs.python.org/3/library/ast.html#abstract-grammar.\n\n        Returns:\n            ast.AST: the original node, which has been potentially modified.\n        \"\"\"\n        for name in node.names:\n            if name.name == GET_IMAGE_URI_NAME:\n                name.name = \"image_uris\"\n            if node.module in GET_IMAGE_URI_NAMESPACES:\n                node.module = \"sagemaker\"\n        return node\n", "path": "src/sagemaker/cli/compatibility/v2/modifiers/image_uris.py"}]}