<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def to_lal_type_str(pytype):
 """Convert the input python type to a LAL type string Examples -------- To convert a python type: 'REAL8' To convert a `numpy.dtype`: 'UINT4' To convert a LAL type code: 'REAL8' Raises ------ KeyError if the input doesn't map to a LAL type string """

    # noop
    if pytype in LAL_TYPE_FROM_STR:
        return pytype

    # convert type code
    if pytype in LAL_TYPE_STR:
        return LAL_TYPE_STR[pytype]

    # convert python type
    try:
        dtype = numpy.dtype(pytype)
        return LAL_TYPE_STR_FROM_NUMPY[dtype.type]
    except (TypeError, KeyError):
        raise ValueError("Failed to map {!r} to LAL type string")