code: def generate_tempdir(directory: str = None, **kwargs):
      """Generate a temporary directory"""
      directory = seg_env.TMP_HOME if not directory else directory
      with tempfile.TemporaryDirectory(dir=directory, **kwargs) as _dir:
          yield _dir
  
imports: import os
  import contextlib
  import tempfile
  import random
  from urllib.parse import urlparse, unquote
  import yaml
  import numpy
  import paddle
  import cv2
  from paddleseg.utils import logger, seg_env, get_sys_env
  from paddleseg.utils.download import download_file_and_uncompress
label_desc: Use image node_id 7 for calling a global function with example usage: generate_tempdir(directory) without return types