code: def _pair_tensor_metadata(
      tensor_md: List[metadata_info.TensorMd],
      tensor_names_from_model: List[str],
  ) -> List[metadata_info.TensorMd]:
      """Pairs tensor_md according to the tensor names from the model."""
      tensor_names_from_arg = [
          md.tensor_name
          for md in tensor_md or []
          if md.tensor_name is not None
      ]
      if not tensor_names_from_arg:
          return tensor_md
  
      if collections.Counter(
          tensor_names_from_arg
      ) != collections.Counter(tensor_names_from_model):
          raise ValueError(
              "The tensor names from arguments ({}) do not match the tensor names"
              " read from the model ({}).".format(
                  tensor_names_from_arg, tensor_names_from_model
              )
          )
      pairs_tensor_md = []
      name_md_dict = dict(zip(tensor_names_from_arg, tensor_md))
      for name in tensor_names_from_model:
          pairs_tensor_md.append(name_md_dict[name])
      return pairs_tensor_md
  
imports: import collections
  import csv
  import dataclasses
  import os
  import tempfile
  from typing import List, Optional, Tuple, Union
  import flatbuffers
  from mediapipe.tasks.metadata import metadata_schema_py_generated
  from mediapipe.tasks.python.metadata import metadata
  from mediapipe.tasks.python.metadata.metadata_writers import metadata_info
  from mediapipe.tasks.python.metadata.metadata_writers import writer_utils
label_desc: Use image node_id 2 for calling a global function with example usage: _pair_tensor_metadata(tensor_md, tensor_names_from_model) and returns: pairs_tensor_md, tensor_md