<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def _check_trace_id(self, trace_id):
 """Check the format of the trace_id to ensure it is 32-character hex value representing a 128-bit number. If trace_id is invalid, returns a randomly generated trace id :type trace_id: str :param trace_id: :rtype: str :returns: Trace_id for the current context. """

        assert isinstance(trace_id, six.string_types)

        if trace_id is _INVALID_TRACE_ID:
            logging.warning(
                'Trace_id {} is invalid (cannot be all zero), '
                'generating a new one.'.format(trace_id))
            self.from_header = False
            return generate_trace_id()

        match = TRACE_ID_PATTERN.match(trace_id)

        if match:
            return trace_id
        else:
            logging.warning(
                'Trace_id {} does not the match the required format,'
                'generating a new one instead.'.format(trace_id))
            self.from_header = False
            return generate_trace_id()