input: Write a function to generate a random password of length 8 characters, which contains at least one of each character type (lowercase, uppercase, digits, special characters). If the password meets the criteria, return the password as a string. If not, return an empty string.
  import string
  import random
  
  def generate_password():
      length = 8
      special_characters = "!#$%&'()*+,-./:;<=>?@[\]^_`{|}~"
      password = random.choice(string.ascii_lowercase)
      password += random.choice(string.ascii_uppercase)
      password += random.choice(string.digits)
      password += random.choice(special_characters)
  
      for i in range(4):
          password += random.choice(string.ascii_lowercase + string.ascii_uppercase + string.digits + special_characters)
  
      password = ''.join(random.sample(password, length))
      
      if any(c in string.ascii_lowercase for c in password) and any(c in string.ascii_uppercase for c in password) and any(c in string.digits for c in password) and any(c in special_characters for c in password):
          return password
      else:
          return ""
  
  assert generate_password() != ""
  assert len(generate_password()) == 8
  assert any(c in string.ascii_lowercase for c in generate_password())
  assert any(c in string.ascii_uppercase for c in generate_password())
  assert any(c in string.digits for c in generate_password())
  assert any(c in "!#$%&'()*+,-./:;<=>?@[\]^_`{|}~" for c in generate_password())
output: import string
  import random
  
  def generate_password():
      length = 8
      special_characters = "!#$%&'()*+,-./:;<=>?@[\]^_`{|}~"
      password = random.choice(string.ascii_lowercase)
      password += random.choice(string.ascii_uppercase)
      password += random.choice(string.digits)
      password += random.choice(special_characters)
  
      for i in range(4):
          password += random.choice(string.ascii_lowercase + string.ascii_uppercase + string.digits + special_characters)
  
      password = ''.join(random.sample(password, length))
      
      if any(c in string.ascii_lowercase for c in password) and any(c in string.ascii_uppercase for c in password) and any(c in string.digits for c in password) and any(c in special_characters for c in password):
          return password
      else:
          return ""