How to add other types of dynamic attributes in the BODY tag?
I think, i found the right solution below:

  if ($node) {
    $variables['attributes']['class'][] = 'page-node';
}


  if ($tid) {
    $variables['attributes']['class'][] = 'term-page';
}  

  if ($tid) {
    $variables['attributes']['class'][] = 'term-page-' . $tid-&gt;id();
}