code: def test_add_reference_via_artifact_entry(user, cleanup):
      """Test adding a reference to an artifact via an ArtifactEntry.
  
      This test is the same as test_artifact_add_reference_via_url, but rather than
      passing the direct URL, we pass an Artifact entry, which will automatically resolve
      to the correct URL.
      """
      upstream_artifact_name = "upstream_artifact"
      middle_artifact_name = "middle_artifact"
      downstream_artifact_name = "downstream_artifact"
  
      upstream_local_path = "upstream/local/path/"
  
      upstream_artifact_path = "upstream/artifact/path/"
      middle_artifact_path = "middle/artifact/path/"
      downstream_artifact_path = "downstream/artifact/path/"
  
      upstream_local_file_path = upstream_local_path + "file.txt"
      upstream_artifact_file_path = upstream_artifact_path + "file.txt"
      middle_artifact_file_path = middle_artifact_path + "file.txt"
      downstream_artifact_file_path = (
          downstream_artifact_path + "file.txt"
      )
  
      file_text = "Luke, I am your Father!!!!!"
      # Create a super important file
      if not os.path.exists(upstream_local_path):
          os.makedirs(upstream_local_path)
      with open(upstream_local_file_path, "w") as file:
          file.write(file_text)
  
      # Create an artifact with such file stored
      with wandb.init() as run:
          artifact = wandb.Artifact(upstream_artifact_name, "database")
          artifact.add_file(
              upstream_local_file_path, upstream_artifact_file_path
          )
          run.log_artifact(artifact)
  
      # Create an middle artifact with such file referenced (notice no need to download)
      with wandb.init() as run:
          artifact = wandb.Artifact(middle_artifact_name, "database")
          upstream_artifact = run.use_artifact(
              upstream_artifact_name + ":latest"
          )
          artifact.add_reference(
              upstream_artifact.get_entry(upstream_artifact_file_path),
              middle_artifact_file_path,
          )
          run.log_artifact(artifact)
  
      # Create a downstream artifact that is referencing the middle's reference
      with wandb.init() as run:
          artifact = wandb.Artifact(
              downstream_artifact_name, "database"
          )
          middle_artifact = run.use_artifact(
              middle_artifact_name + ":latest"
          )
          artifact.add_reference(
              middle_artifact.get_entry(middle_artifact_file_path),
              downstream_artifact_file_path,
          )
          run.log_artifact(artifact)
  
      # Remove the directories for good measure
      if os.path.isdir("upstream"):
          shutil.rmtree("upstream")
      if os.path.isdir("artifacts"):
          shutil.rmtree("artifacts")
  
      # Finally, use the artifact (download it) and enforce that the file is where we want it!
      with wandb.init() as run:
          downstream_artifact = run.use_artifact(
              downstream_artifact_name + ":latest"
          )
          downstream_path = downstream_artifact.download()
          downstream_path = (
              downstream_artifact.download()
          )  # should not fail on second download.
          # assert os.path.islink(
          #     os.path.join(downstream_path, downstream_artifact_file_path)
          # )
          with open(
              os.path.join(
                  downstream_path, downstream_artifact_file_path
              )
          ) as file:
              assert file.read() == file_text
  
imports: import base64
  import binascii
  import os
  import shutil
  import time
  from math import cos, pi, sin
  import boto3
  import botocore
  import google.cloud.storage
  import numpy
  import pytest
  import wandb
  from bokeh.plotting import figure
  from wandb.sdk.artifacts.storage_handlers.gcs_handler import GCSHandler
  from wandb.sdk.artifacts.storage_handlers.s3_handler import S3Handler
label_desc: Use image node_id 11 for calling a global function with example usage: test_add_reference_via_artifact_entry(user, cleanup) without return types