code: def format_vars(resolved_vars: Dict) -> str:
      """Format variables to be used as experiment tags.
  
      Experiment tags are used in directory names, so this method makes sure
      the resulting tags can be legally used in directory names on all systems.
  
      The input to this function is a dict of the form
      ``{("nested", "config", "path"): "value"}``. The output will be a comma
      separated string of the form ``last_key=value``, so in this example
      ``path=value``.
  
      Note that the sanitizing implies that empty strings are possible return
      values. This is expected and acceptable, as it is not a common case and
      the resulting directory names will still be valid.
  
      Args:
          resolved_vars: Dictionary mapping from config path tuples to a value.
  
      Returns:
          Comma-separated key=value string.
      """
      vars = resolved_vars.copy()
      # TrialRunner already has these in the experiment_tag
      for v in ["run", "env", "resources_per_trial"]:
          vars.pop(v, None)
  
      return ",".join(
          f"{_clean_value(k[-1])}={_clean_value(v)}"
          for k, v in sorted(vars.items())
      )
  
imports: import copy
  import logging
  import re
  from collections.abc import Mapping
  from typing import Any, Dict, Generator, Iterable, List, Optional, Tuple
  import numpy
  import random
  from ray.tune.search.sample import Categorical, Domain, Function, RandomState
  from ray.util.annotations import DeveloperAPI, PublicAPI
label_desc: Use image node_id 4 for calling a global function with example usage: format_vars(resolved_vars) and returns: str