code: def _sanitize_filename_for_docker_tag(filename: str) -> str:
      """Convert a filename to a valid docker tag.
      See https://docs.docker.com/engine/reference/commandline/tag/ for valid tag
      format.
  
      Args:
          filename (str): The filename to be converted.
  
      Returns:
          str: The sanitized Docker tag.
      """
      # Replace any character not allowed with an underscore
      allowed_chars = set(string.ascii_letters + string.digits + "_.-")
      sanitized = "".join(
          char if char in allowed_chars else "_" for char in filename
      )
  
      # Ensure it does not start with a period or a dash
      if sanitized.startswith(".") or sanitized.startswith("-"):
          sanitized = "_" + sanitized[1:]
  
      # Truncate if longer than 128 characters
      return sanitized[:128]
  
imports: import logging
  import os
  import pathlib
  import re
  import string
  import subprocess
  import sys
  import time
  from concurrent.futures import ThreadPoolExecutor, TimeoutError
  from hashlib import md5
  from typing import Callable, Dict, List, Optional, Tuple, Union
  from autogen import oai
label_desc: Use image node_id 9 for calling a global function with example usage: _sanitize_filename_for_docker_tag(filename) and returns: sanitized