1""" 2This makes the functions in torch._C._VariableFunctions available as 3 torch._VF.<funcname> 4without mypy being able to find them. 5 6A subset of those functions are mapped to ATen functions in 7torch/jit/_builtins.py 8 9See https://github.com/pytorch/pytorch/issues/21478 for the reason for 10introducing torch._VF 11 12""" 13 14import sys 15import types 16 17import torch 18 19 20class VFModule(types.ModuleType): 21 vf: types.ModuleType 22 23 def __init__(self, name: str): 24 super().__init__(name) 25 self.vf = torch._C._VariableFunctions 26 27 def __getattr__(self, name: str) -> object: 28 return getattr(self.vf, name) 29 30 31sys.modules[__name__] = VFModule(__name__) 32