code: def apply_chunked(func, chunk_generator, tensor_collator):
      """
      Helper function to apply a function on a sequence of
      chunked inputs yielded by a generator and collate
      the result.
      """
      processed_chunks = [
          func(*chunk_args, **chunk_kwargs)
          for chunk_args, chunk_kwargs in chunk_generator
      ]
  
      return cat_dataclass(processed_chunks, tensor_collator)
  
file_path: pytorch3d/pytorch3d/implicitron/models/utils.py
imports: import warnings
  from logging import Logger
  from typing import Any, Dict, Optional, Tuple
  import torch
  import tqdm
  from pytorch3d.common.compat import prod
  from pytorch3d.implicitron.models.renderer.base import ImplicitronRayBundle
  from pytorch3d.implicitron.tools import image_utils
  from pytorch3d.implicitron.tools.utils import cat_dataclass
label_desc: Use image node_id 4 for calling a global function with example usage: apply_chunked(func, chunk_generator, tensor_collator) and returns: cat_dataclass