code: def fastface_collate_fn(
      samples: Sequence[Dict[str, Any]]
  ) -> Dict[str, Sequence[Any]]:
      """Collate function from fastface.
  
      Organizes individual elements in a batch, calls prepare_batch from fastface and prepares the targets.
  
      """
      samples = {
          key: [sample[key] for sample in samples] for key in samples[0]
      }
  
      images, scales, paddings = ff.utils.preprocess.prepare_batch(
          samples[DataKeys.INPUT], None, adaptive_batch=True
      )
  
      samples["scales"] = scales
      samples["paddings"] = paddings
  
      if DataKeys.TARGET in samples:
          targets = samples[DataKeys.TARGET]
  
          for i, (target, scale, padding) in enumerate(
              zip(targets, scales, paddings)
          ):
              target["target_boxes"] *= scale
              target["target_boxes"][:, [0, 2]] += padding[0]
              target["target_boxes"][:, [1, 3]] += padding[1]
              targets[i]["target_boxes"] = target["target_boxes"]
  
          samples[DataKeys.TARGET] = targets
      samples[DataKeys.INPUT] = images
  
      return samples
  
file_path: lightning-flash/src/flash/image/face_detection/input_transform.py
imports: from dataclasses import dataclass
  from typing import Any, Callable, Dict, Sequence
  import torch
  from flash.core.data.io.input import DataKeys
  from flash.core.data.io.input_transform import InputTransform
  from flash.core.data.transforms import ApplyToKeys
  from flash.core.utilities.imports import _FASTFACE_AVAILABLE, _TORCHVISION_AVAILABLE
label_desc: Use image node_id 1 for calling a global function with example usage: fastface_collate_fn(samples) and returns: samples