def write_arbitrary_beam_section(inps, ts, branch_paths, nsm, outp_id, core
    =None):
    """writes the PBRSECT/PBMSECT card"""
    end = ''
    for key, dicts in [('INP', inps), ('T', ts), ('BRP', branch_paths), (
        'CORE', core)]:
        if dicts is None:
            continue
        for index, value1 in sorted(dicts.items()):
            if index == 0:
                if isinstance(value1, list):
                    for value1i in value1:
                        end += '        %s=%s,\n' % (key, value1i)
                else:
                    end += '        %s=%s,\n' % (key, value1)
            elif isinstance(value1, list):
                if len(value1) == 2:
                    assert len(value1) == 2, value1
                    thicknessi = value1[0]
                    points = value1[1]
                    end += '        %s(%s)=[%s, PT=(%s,%s)],\n' % (key,
                        index, thicknessi, points[0], points[1])
                else:
                    assert len(value1) == 1, value1
                    end += '        %s=%s,\n' % (key, value1[0])
            else:
                end += '        %s(%s)=%s,\n' % (key, index, value1)
    for key, value in [('NSM', nsm), ('outp', outp_id)]:
        if value:
            end += '        %s=%s,\n' % (key, value)
    if end:
        end = end[:-2] + '\n'
    return end
