code: def map_annotation(
      annotation: Any,
      mapping: Optional[Dict[Any, Any]] = None,
  ) -> Any:
      origin = getattr(annotation, "__origin__", None)
      args = getattr(annotation, "__args__", [])
      if origin == Union or origin == list or origin == dict:
          annotation = copy.copy(annotation)
          annotation.__args__ = tuple(
              map_annotation(a, mapping) for a in args
          )
          return annotation
  
      if mapping is not None and annotation in mapping:
          return mapping[annotation]
  
      out = dataclass_from_class(annotation)
      if out is not None:
          return out
  
      return annotation
  
file_path: pytorch_geometric/torch_geometric/config_store.py
imports: import copy
  import inspect
  import typing
  from collections import defaultdict
  from dataclasses import dataclass, field, make_dataclass
  from typing import Any, Callable, Dict, List, Optional, Tuple, Union
  import torch
label_desc: Use image node_id 1 for calling a global function with example usage: map_annotation(annotation, mapping) and returns: annotation, annotation, mapping, out