code: def get_used_tokens_for_ecd(
      inputs: Dict[str, torch.Tensor], targets: Dict[str, torch.Tensor]
  ) -> int:
      """Returns the number of used tokens for an ECD model.
  
      The number of used tokens is the total size of the input and output tensors, which corresponds to 1 token for
      binary, category, and number features, and variable number of tokens for text features, for each example in the
      batch.
  
      Args:
          inputs: The input tensors for one forward pass through ecd.
          targets: The target tensors for one forward pass through ecd.
      """
      used_tokens = 0
      for input_feature_tensor in inputs.values():
          used_tokens += torch.flatten(input_feature_tensor).shape[0]
      if targets is not None:
          # targets may be None for evaluation.
          for output_feature_tensor in targets.values():
              used_tokens += torch.flatten(output_feature_tensor).shape[
                  0
              ]
      return used_tokens
  
imports: from typing import Dict, Union
  import torch
label_desc: Use image node_id 2 for calling a global function with example usage: get_used_tokens_for_ecd(inputs, targets) and returns: used_tokens