Assuming that the argument is a node ID, being sent (say from a panel, under most circumstances)
// grab nid from referring node
$args[0]=arg(1);
if(is_numeric(arg(1))){
$nid = arg(1); //node id
$term = taxonomy_node_get_terms_by_vocabulary($nid, 3); // 3 is the vid. Use your own Vocabualary ID!
$tids=key($term);
return $tids;
}
$args[1]=$tids;