code: def prepare_response_header(origin_header, segment):
      
      if origin_header and origin_header.sampled == '?':
          new_header = TraceHeader(root=segment.trace_id,
                                   sampled=segment.sampled)
      else:
          new_header = TraceHeader(root=segment.trace_id)
  
      return new_header.to_header_str()
docs: Prepare a trace header to be inserted into response
      based on original header and the request segment.