input: Write a function to parse a JSON data structure and return the name, age, and occupation extracted from the data. The function should take the JSON string as input and return a tuple containing the name, age, and occupation. If the JSON string is invalid or any of the required keys are missing, the function should return None for those values.
  
  def parse_json(data):
      try:
          parsed_data = json.loads(data)
          name = parsed_data.get('name', None)
          age = parsed_data.get('age', None)
          occupation = parsed_data.get('occupation', None)
          return name, age, occupation
      except json.JSONDecodeError:
          return None, None, None
  
  data_str = '{"name": "John", "age": 18, "occupation": "Software Engineer"}'
  name, age, occupation = parse_json(data_str)
  print(name, age, occupation)  # Output: John 18 Software Engineer
  
  assert parse_json('{"name": "John", "age": 18, "occupation": "Software Engineer"}') == ("John", 18, "Software Engineer")
  assert parse_json('{"name": "Jane", "age": 25, "occupation": "Teacher"}') == ("Jane", 25, "Teacher")
  assert parse_json('{"name": "Alex", "age": 30}') == ("Alex", 30, None)
  assert parse_json('{"age": 22, "occupation": "Student"}') == (None, 22, "Student")
  assert parse_json('{"name": "Sam"}') == ("Sam", None, None)
  assert parse_json('{invalid json}') == (None, None, None)
output: 
  def parse_json(data):
      try:
          parsed_data = json.loads(data)
          name = parsed_data.get('name', None)
          age = parsed_data.get('age', None)
          occupation = parsed_data.get('occupation', None)
          return name, age, occupation
      except json.JSONDecodeError:
          return None, None, None
  