code: def add_view_copy_derivatives(
      infos: Dict[FunctionSchema, Dict[str, DifferentiabilityInfo]],
      view_groups: List[NativeFunctionsViewGroup],
  ) -> None:
      # Get the map from each view op's name to its corresponding view group
      view_name_to_group: Dict[
          OperatorName, NativeFunctionsViewGroup
      ] = {g.view.func.name: g for g in view_groups}
  
      view_infos = {}
  
      for info_dispatch_dict in infos.values():
          # maybe_view_group only needs to be calculated once per info_dispatch_dict
          maybe_view_group = None
          view_copy_differentiability_infos = {}
          for dispatch_key, info in info_dispatch_dict.items():
              maybe_view_group = view_name_to_group.get(
                  info.func.func.name, None
              )
              if (
                  maybe_view_group is not None
                  and maybe_view_group.view_copy is not None
              ):
                  view_copy_info = (
                      info.create_view_copy_from_view_derivative(
                          maybe_view_group
                      )
                  )
                  if view_copy_info is not None:
                      fn_schema = view_copy_info.func.func
                      view_copy_differentiability_infos[
                          dispatch_key
                      ] = view_copy_info
              else:
                  break
          # prefer manually-defined derivatives if any
          if (
              len(view_copy_differentiability_infos) > 0
              and fn_schema not in infos
          ):
              assert fn_schema is not None
              view_infos[fn_schema] = view_copy_differentiability_infos
  
      infos.update(view_infos)
  
imports: import re
  from collections import defaultdict
  from typing import Any, Counter, Dict, List, Match, Optional, Sequence, Set, Tuple
  import yaml
  from torchgen.api import cpp
  from torchgen.api.autograd import Derivative, DifferentiabilityInfo, ForwardDerivative, SavedAttribute
  from torchgen.api.types import BaseCType, Binding, boolT, CppSignatureGroup, layoutT, longT, NamedCType, OptionalCType, scalarTypeT, SpecialArgName, stringT, symIntArrayRefT, SymIntT, tensorGeometryT, tensorOptionsT, typeAndSizeT, VectorCType
  from torchgen.context import with_native_function
  from torchgen.gen import get_grouped_by_view_native_functions, parse_native_yaml
  from torchgen.model import AUTOGRAD_KEYS, FunctionSchema, NativeFunction, NativeFunctionsViewGroup, OperatorName, SchemaKind, Type, Variant
  from torchgen.utils import concatMap, IDENT_REGEX, split_name_params
  from torchgen.yaml_utils import YamlLoader
label_desc: Use image node_id 1 for calling a global function with example usage: add_view_copy_derivatives(infos, view_groups) without return types