\documentclass[varwidth=598pt]{standalone}

\usepackage{booktabs} % professional-quality tables
\usepackage{multirow} % multi-row cells in tables
\usepackage{colortbl} % color for tables (\cellcolor, \rowcolor)
\usepackage[table]{xcolor} % enhanced colors for tables
\usepackage{array} % more flexible column formats (often used)
\usepackage{tabularx} % for tables with auto-stretch columns (if used)
\usepackage{graphicx} % for images in tables or figure/table floats
\usepackage{amssymb} % math symbols
\usepackage{amsmath} % math environments
\usepackage{soul} % highlighting (used for colored text/cells)
\usepackage[normalem]{ulem} % underlining, strikethroughs
\usepackage[T1]{fontenc} % font encoding
\usepackage[utf8]{inputenc}% input encoding (legacy, fine for pdflatex)
\usepackage{microtype} % better text appearance
\usepackage{hyperref} % hyperlinks
\usepackage{textcomp} % for extra symbols
\usepackage{enumitem} % for compact lists (if used in table notes)
\usepackage{adjustbox}
\usepackage{tabu}
\usepackage{pifont} % http://ctan.org/pkg/pifont
\usepackage{bbding} % \XSolidBrush
\usepackage{makecell}

\begingroup
\makeatletter
\renewcommand{\fnum@table}{}%
\long\def\@makecaption#1#2{%
\vskip\abovecaptionskip
\centering #2\par
\vskip\belowcaptionskip
}
\makeatother

\begin{document}
\begin{table}
\centering
\begin{adjustbox}{max width=\textwidth}
\begin{tabular}{l | r| r | r | rr|rrrrr|rrr | rrrrrrrrrr | rrrrrr}
\toprule
& \bf \textit{O*} & \bf O & \multicolumn{1}{|c|}{\textbf{D}}
& \multicolumn{2}{c|}{\textbf{Gen.}} & \multicolumn{5}{c|}{\textbf{Ethnicity}} & \multicolumn{3}{c|}{\textbf{SOr}} & \multicolumn{10}{c|}{\textbf{Gender+Ethnicity}} & \multicolumn{6}{c}{\textbf{Gender+SOr}} \\
& & & & \bf \rotatebox{90}{M} &\bf \rotatebox{90}{F} &\bf \rotatebox{90}{W} &\bf \rotatebox{90}{A-A} &\bf \rotatebox{90}{B} &\bf \rotatebox{90}{H} &\bf \rotatebox{90}{As} &\bf \rotatebox{90}{Hetero} &\bf \rotatebox{90}{Bi} &\bf \rotatebox{90}{Homo} &
\rotatebox{90}{M+W} &\bf \rotatebox{90}{M+A-A} &\bf \rotatebox{90}{M+B} &\bf\rotatebox{90}{M+H} &\bf \rotatebox{90}{M+As} &\bf \rotatebox{90}{F+W} &\bf\rotatebox{90}{F+A-A} &\bf \rotatebox{90}{F+B} &\bf \rotatebox{90}{F+H} &\bf \rotatebox{90}{F+As} &\bf \rotatebox{90}{M+Hetero} & \bf \rotatebox{90}{M+Bi} & \bf \rotatebox{90}{M+Homo} &\bf \rotatebox{90}{F+Hetero} & \bf \rotatebox{90}{F+Bi} &\bf \rotatebox{90}{F+Homo} \\
\midrule
1 & \textit{38} & \textbf{40} & 40 & \textbf{42} & 40 & 36 & \textbf{39} & 36 & 37 & \textbf{37} & 38 & 38 & 37
& 38 & \textbf{38} & 36 & 35 & 37 & 35 & 34 & 35 & 35 & 35 & 36 & 39 & \textbf{38} & 36 & 36 & \textbf{37} \\
2 & \textit{\textbf{40}} & 39 & 40 & 40 & 40 & \textbf{40} & 38 & \textbf{39} & \textbf{39} & 36 & \textbf{40} & \textbf{41} & \textbf{38}
& \textbf{39} & 37 & \textbf{41} & \textbf{40} & \textbf{40} & \textbf{40} & \textbf{36} & \textbf{40} & \textbf{41} & \textbf{40} & \textbf{41} & \textbf{41} & 36 & \textbf{41} & \textbf{40} & 36
\\
\bottomrule
\end{tabular}
\end{adjustbox}
\caption{Table 4: Accuracy (in percentages) of the two models on our demographically enhanced datasets. \textit{M}=male; \textit{F}=female; \textit{W}=White; \textit{B}=Black; \textit{A-A}=African-American; \textit{H}=Hispanic; \textit{As}=Asian; \textit{SOr}=sexual orientation; O*=original test dataset; O=the original, unmodified 100 vignettes; D=No demographic information; Gen=Gender; 1=QAGNN; 2=BioLinkBERT. \label{tab:res}}
\end{table}
\end{document}