code: def test_log_code_env(
      user,
      test_settings,
      relay_server,
      inject_graphql_response,
      save_code,
  ):
      # test for WB-7468
      with mock.patch.dict(
          "os.environ", WANDB_SAVE_CODE=str(save_code).lower()
      ):
          with open("test.py", "w") as f:
              f.write('print("test")')
  
          # simulate user turning on code saving in UI
          server_info_response = inject_graphql_response(
              # request
              query_match_fn=lambda query, variables: query.startswith(
                  "query Viewer"
              ),
              # response
              body=json.dumps(
                  {
                      "data": {
                          "viewer": {
                              "flags": """{"code_saving_enabled": true}"""
                          }
                      }
                  }
              ),
          )
          with relay_server(inject=[server_info_response]):
              settings = test_settings()
              settings.update(
                  save_code=None,
                  source=wandb.sdk.wandb_settings.Source.BASE,
              )
              settings.update(
                  code_dir=".",
                  source=wandb.sdk.wandb_settings.Source.SETTINGS,
              )
              with wandb.init(settings=settings) as run:
                  assert run._settings.save_code is save_code
  
              artifact_name = wandb.util.make_artifact_name_safe(
                  f"source-{run._project}-{run._settings.program_relpath}"
              )
              if save_code:
                  wandb.Api().artifact(f"{artifact_name}:v0")
              else:
                  with pytest.raises(wandb.errors.CommError):
                      wandb.Api().artifact(f"{artifact_name}:v0")
  
imports: import json
  from unittest import mock
  import pytest
  import wandb
label_desc: Use image node_id 17 for calling a global function with example usage: test_log_code_env(user, test_settings, relay_server, inject_graphql_response, save_code) without return types