code: def test_variable_in_task(loop):
      port = open_port()
      # Ensure that we can create a Variable inside a task on a
      # worker in a separate Python process than the client
      with popen(
          ["dask", "scheduler", "--no-dashboard", "--port", str(port)]
      ):
          with popen(["dask", "worker", f"127.0.0.1:{port}"]):
              with Client(f"tcp://127.0.0.1:{port}", loop=loop) as c:
                  c.wait_for_workers(1)
  
                  x = Variable("x")
                  x.set(123)
  
                  def foo():
                      y = Variable("x")
                      return y.get()
  
                  result = c.submit(foo).result()
                  assert result == 123
  
file_path: distributed/distributed/tests/test_variable.py
imports: from __future__ import annotations
  import asyncio
  import pickle
  import random
  from datetime import timedelta
  from time import sleep
  import pytest
  from distributed import Client, Nanny, TimeoutError, Variable, wait, worker_client
  from distributed.compatibility import WINDOWS
  from distributed.metrics import monotonic, time
  from distributed.utils import open_port
  from distributed.utils_test import captured_logger, div, gen_cluster, inc, popen
label_desc: Use image node_id 1 for calling a global function with example usage: test_variable_in_task(loop) and returns: y