code: def xor_gate(variables, vartype=dimod.BINARY, name='XOR'):
      
  
      variables = tuple(variables)
      if vartype is dimod.BINARY:
          configs = frozenset([(0, 0, 0),
                               (0, 1, 1),
                               (1, 0, 1),
                               (1, 1, 0)])
  
          def func(in1, in2, out): return (in1 != in2) == out
  
      else:
          # SPIN, vartype is checked by the decorator
          configs = frozenset([(-1, -1, -1),
                               (-1, +1, +1),
                               (+1, -1, +1),
                               (+1, +1, -1)])
  
          def func(in1, in2, out): return ((in1 > 0) != (in2 > 0)) == (out > 0)
  
      return Constraint(func, configs, variables, vartype=vartype, name=name)
docs: XOR gate.
  
      Args:
          variables (list): Variable labels for the and gate as `[in1, in2, out]`,
              where `in1, in2` are inputs and `out` the gate's output.
          vartype (Vartype, optional, default='BINARY'): Variable type. Accepted
              input values:
  
              * Vartype.SPIN, 'SPIN', {-1, 1}
              * Vartype.BINARY, 'BINARY', {0, 1}
          name (str, optional, default='XOR'): Name for the constraint.
  
      Returns:
          Constraint(:obj:`.Constraint`): Constraint that is satisfied when its variables are
          assigned values that match the valid states of an XOR gate.
  
      Examples:
          >>> import dwavebinarycsp
          >>> import dwavebinarycsp.factories.constraint.gates as gates
          >>> csp = dwavebinarycsp.ConstraintSatisfactionProblem(dwavebinarycsp.BINARY)
          >>> csp.add_constraint(gates.xor_gate(['x', 'y', 'z'], name='XOR1'))
          >>> csp.check({'x': 1, 'y': 1, 'z': 1})
          False