code: def gen_functionalization_registration(
      selector: SelectiveBuilder,
      g: Union[
          NativeFunction, NativeFunctionsGroup, NativeFunctionsViewGroup
      ],
      composite_implicit_autograd_index: BackendIndex,
  ) -> List[str]:
      @with_native_function
      def emit_registration_helper(f: NativeFunction) -> str:
          assert not f.has_composite_implicit_autograd_kernel
          registration_str = (
              f"TORCH_FN(functionalization::{wrapper_name(f.func)})"
          )
          return f'm.impl("{f.func.name}", {registration_str});'
  
      # Don't generate kernels in mobile build
      if not selector.include_all_operators:
          return []
  
      if isinstance(g, NativeFunctionsViewGroup):
          # functionalization needs to register kernels for view + view_inplace ops
          # See Note [Functionalization <> torch.Tensor constructor]
          if str(g.view.func.name) == "lift_fresh":
              return []
          view_str = []
          if not g.view.has_composite_implicit_autograd_kernel:
              view_str.append(emit_registration_helper(g.view))
          if (
              g.view_inplace is not None
              and not g.view_inplace.has_composite_implicit_autograd_kernel
          ):
              assert g.view_inplace.is_view_op
              view_str.append(emit_registration_helper(g.view_inplace))
          return view_str
  
      elif isinstance(g, NativeFunctionsGroup):
          # Gets a hand-written functionalization kernel
          if (
              g.inplace is not None
              and str(g.inplace.func.name) == "set_.source_Tensor"
          ):
              fns = []
          else:
              fns = list(g.functions())
      else:
          if (
              str(g.func.name)
              in MUTABLE_OPS_NOT_USING_FUNCTIONALIZATION
          ):
              return []
          fns = [g]
  
      registrations = []
      for f in fns:
          if f.has_composite_implicit_autograd_kernel:
              continue
          if str(f.func.name) == "lift":
              # See Note [Functionalization <> torch.Tensor constructor]
              return []
          if str(f.func.name) == "resize_":
              # See Note [resize_ in Functionalization]
              return []
          assert not f.is_view_op
          # functionalization needs to generate and register kernels for inplace ops.
          # We *also* need to directly register CompositeImplicitAUtograd kernels
          # so that they decompose properly before functioanlization.
          if modifies_arguments(f):
              registrations.append(emit_registration_helper(f))
      return registrations
  
imports: from dataclasses import dataclass
  from typing import Callable, List, Optional, Tuple, Union
  from torchgen.api import cpp, dispatcher
  from torchgen.api.translate import translate
  from torchgen.api.types import BaseCType, Binding, CType, DispatcherSignature, FunctionalizationLambda, iTensorListRefT, NativeSignature, tensorListT, tensorT, VectorCType, ViewInverseSignature
  from torchgen.context import method_with_native_function, native_function_manager, with_native_function, with_native_function_and
  from torchgen.model import Argument, BackendIndex, BaseTy, BaseType, FunctionSchema, ListType, NativeFunction, NativeFunctionsGroup, NativeFunctionsViewGroup, Return, SchemaKind, SelfArgument, TensorOptionsArguments
  from torchgen.native_function_generation import INPLACE_OPS_THAT_DONT_GET_GROUPED_PROPERLY, MUTABLE_OPS_THAT_CANNOT_GET_AN_OUT_VARIANT, OUT_OPS_THAT_DONT_GET_GROUPED_PROPERLY
  from torchgen.selective_build.selector import SelectiveBuilder
label_desc: Use image node_id 16 for calling a global function with example usage: gen_functionalization_registration(selector, g, composite_implicit_autograd_index) and returns: registrations, str, f, str, registration_str, str, list, view_str, list, list, list, list