If value is an int, return the same int (type must be int).
If value is a float and value.is_integer() is True, return the integer value (as int).
If value is a float and value.is_integer() is False, return the original float (type must be float).
For any other (non-numeric) input, raise a TypeError with a clear, descriptive message.
Type hints: Use typing.Union[int, float] for both input and return type to reflect possible results.
Documentation: Include a brief docstring describing the function’s purpose, input types, and return behavior.
Edge cases:
_optional_int(1) -> 1 (int)
_optional_int(1.0) -> 1 (int)
_optional_int(1.2) -> 1.2 (float)
Compatibility with tests: The implementation must satisfy tests that import _optional_int from averager and assert both value and type for ints, integral floats, and non-integral floats as described.