input: Write a python function to generate a random password of a given length using the provided character set.
  assert len(generate_password(8)) == 8
  assert len(generate_password(12)) == 12
  assert any(char in '!@#$%^&*()_+~<>?' for char in generate_password(10))
  assert any(char.isdigit() for char in generate_password(10))
  assert any(char.islower() for char in generate_password(10))
  assert any(char.isupper() for char in generate_password(10))
output: import random
  import string
  
  def generate_password(length):
      if length < 4:
          raise ValueError("Password length should be at least 4 characters.")
  
      char_set = string.ascii_letters + string.digits + '!@#$%^&*()_+~<>?'
      password = [
          random.choice(string.ascii_lowercase),
          random.choice(string.ascii_uppercase),
          random.choice(string.digits),
          random.choice('!@#$%^&*()_+~<>?')
      ]
  
      password += random.choices(char_set, k=length-4)
      random.shuffle(password)
      
      return ''.join(password)