code: def pad_and_tensorize_batches(tensorizers, batches):
      for raw_batch, numberized_batch in batches:
          tensor_dict = {}
          for name, tensorizer in tensorizers.items():
              if isinstance(tensorizer, MetricTensorizer):
                  tensor_dict[name] = tensorizer.tensorize(
                      numberized_batch
                  )
              else:
                  tensor_dict[name] = tensorizer.tensorize(
                      numberized_batch[name]
                  )
  
          yield raw_batch, tensor_dict
  
imports: import functools
  import itertools
  import math
  import random
  from typing import Any, Dict, Iterable, List, MutableMapping, NamedTuple, Optional, Type
  from pytext.common.constants import RawExampleFieldName, Stage
  from pytext.config.component import Component, ComponentType, create_component, Registry
  from pytext.utils.usage import log_class_usage
  from .sources import DataSource, RawExample, TSVDataSource
  from .sources.data_source import GeneratorIterator, RowShardedDataSource, ShardedDataSource
  from .tensorizers import initialize_tensorizers, MetricTensorizer, Tensorizer
label_desc: Use image node_id 1 for calling a global function with example usage: pad_and_tensorize_batches(tensorizers, batches) without return types