def stoprec_analysis_rltnshp(in_dt, out_dt, start_span, end_span):
    """
    Determines relationship type of stop record to analysis date range.
    
    Parameters
    ----------


    Returns
    -------   
    Returns a string, either 'inner', 'left', 'right, 'outer', 
    'backwards', 'none' depending
    on the relationship between the stop record being analyzed and the
    analysis date range.
    
    Type 'inner':
        
         |-------------------------|
     start_span                  end_span
              |--------------|
             in_dt         out_dt
             
    Type 'left':
        
                    |-------------------------|
                  start_span                end_span
              |--------------|
             in_dt         out_dt
             
    Type 'right':
        
                    |-------------------------|
                  start_span                end_span
                                       |--------------|
                                     in_dt         out_dt
             
    Type 'outer':
        
              |-------------------------|
            start_span                end_span
       |-------------------------------------|
     in_dt                              out_dt   
     
    
    Type 'backwards':
        The exit time is BEFORE the entry time. This is a BAD record.
    
    Type 'none':
        Ranges do not overlap
    """

    if in_dt > out_dt:
        return 'backwards'
    elif (start_span <= in_dt < end_span) and (start_span <= out_dt < end_span):
        return 'inner'
    elif (start_span <= in_dt < end_span) and (out_dt >= end_span):
        return 'right'
    elif (in_dt < start_span) and (start_span <= out_dt < end_span):
        return 'left'
    elif (in_dt < start_span) and (out_dt >= end_span):
        return 'outer'
    else:
        return 'none'