input: from typing import List
  
  def find_duplicate_xor(nums: List[int]) -> int:
      """
      Given an array nums, where each element occurs either once or twice,
      return the XOR of all elements that appear twice in the array. If no elements are duplicated, return 0.
  
      Examples:
      >>> nums = [1, 2, 1, 3]
      1
      >>> nums = [1, 2, 3]
      0
  
      Constraints:
      1 <= nums.length <= 50
      1 <= nums[i] <= 50
      Each element in nums appears either once or twice.
      """
output:     element_count = {}
      for num in nums:
          if num in element_count:
              element_count[num] += 1
          else:
              element_count[num] = 1
  
      result = 0
      for num, count in element_count.items():
          if count == 2:
              result ^= num
  
      return result