What is the right way to count filled multi value field values in drupal? I've a term reference multi value field.  What is the right way to count filled values which is also portable to D8, D9 etc.

The dsm output shows like this:
$wrapper = entity_metadata_wrapper('entity_type', $entity);
dpm($wrapper-&gt;{FIELD_NAME}-&gt;count());


Dealing with entity reference field you can get the identifires like this:

dpm($wrapper-&gt;{FIELD_NAME}-&gt;value(array('identifier' =&gt; TRUE)));