code: def create_torch_distributed_anchor(task_id):
      """
      This will create a temporary file to pass the Task ID created by local_rank 0 of
      if None local rank 0 is calling this file, it
  
      Only call when running locally (i.e. without an agent),
      if running remotely there is no need to pass Task ID, it will be passed externally
      """
      local_file_name = ".clearml_torch_distributed_id"
  
      if get_torch_local_rank() != 0:
          return
  
      torch_dist_path = os.environ.get("TORCHELASTIC_ERROR_FILE")
  
      if not torch_dist_path:
          return
  
      # noinspection PyBroadException
      try:
          torch_dist_path = Path(torch_dist_path).parent.parent.parent
          # create the file
          with open(torch_dist_path / local_file_name, "wt") as f:
              f.write(str(task_id) + "\n")
      except Exception:
          # we failed for some reason?
          getLogger().warning(
              "Failed creating torch task ID anchor file: {}".format(
                  torch_dist_path
              )
          )
  
imports: import os
  from logging import getLogger
  from time import sleep, time
  from pathlib2 import Path
label_desc: Use image node_id 2 for calling a global function with example usage: create_torch_distributed_anchor(task_id) without return types