code: def test_required_and_optional_validation(self):
      def foo(x, y=2):  # pylint: disable=unused-argument
          pass
  
      constraint = function_type.FunctionType.from_callable(foo)
      constraint.bind(*(1, 2))
      constraint.bind(*(), **{"x": 1, "y": 2})
      constraint.bind(*(1,), **{"y": 2})
      constraint.bind(*(1,))
      constraint.bind(*(), **{"x": 1})
  
      with self.assertRaisesRegex(
          TypeError, "too many positional arguments"
      ):
          constraint.bind(*(1, 2, 3))
  
      with self.assertRaisesRegex(
          TypeError, "multiple values for argument 'x'"
      ):
          constraint.bind(*(1,), **{"x": 2})
  
      with self.assertRaisesRegex(
          TypeError, "got an unexpected keyword argument 'z'"
      ):
          constraint.bind(*(1, 2), **{"z": 2})
  
      with self.assertRaisesRegex(
          TypeError, "missing a required argument: 'x'"
      ):
          constraint.bind(*(), **{"z": 3})
  
imports: import collections
  import pickle
  import platform
  from absl.testing import parameterized
  from tensorflow.core.function import trace_type
  from tensorflow.core.function.polymorphism import function_type
  from tensorflow.core.function.polymorphism import function_type_pb2
  from tensorflow.core.function.trace_type import serialization
  from tensorflow.python.framework import func_graph
  from tensorflow.python.platform import test
  from tensorflow.python.types import trace
label_desc: Use image node_id 8 for calling the FunctionTypeTest obj's underlying member method code with example usage: obj.test_required_and_optional_validation() without return types