Skip to content

Fix type annotations and make MyPy run on torch/ - #36584

Closed
rgommers wants to merge 27 commits into
pytorch:masterfrom
rgommers:mypy
Closed

rgommers wants to merge 27 commits into
pytorch:masterfrom
rgommers:mypy

Conversation

@rgommers

Copy link
Copy Markdown
Collaborator

This PR fixes a couple of syntax errors in torch/ that prevent MyPy from running, fixes simple type annotation errors (e.g. missing from typing import List, Tuple, Optional), and adds granular ignores for errors in particular modules as well as for missing typing in third party packages.

As a result, running mypy in the root dir of the repo now runs on:

  • torch/
  • aten/src/ATen/function_wrapper.py (the only file already covered in CI)

In CI this runs on GitHub Actions, job Lint, sub-job "quick-checks", task "MyPy typecheck". It should give (right now): Success: no issues found in 329 source files.

Here are the details of the original 855 errors when running mypy torch on current master (after fixing the couple of syntax errors that prevent mypy from running through):

Details
torch/utils/tensorboard/_proto_graph.py:1: error: Cannot find implementation or library stub for module named 'tensorboard.compat.proto.node_def_pb2'
torch/utils/tensorboard/_proto_graph.py:2: error: Cannot find implementation or library stub for module named 'tensorboard.compat.proto.attr_value_pb2'
torch/utils/tensorboard/_proto_graph.py:3: error: Cannot find implementation or library stub for module named 'tensorboard.compat.proto.tensor_shape_pb2'
torch/utils/backcompat/__init__.py:1: error: Cannot find implementation or library stub for module named 'torch._C'
torch/for_onnx/__init__.py:1: error: Cannot find implementation or library stub for module named 'torch.for_onnx.onnx'
torch/cuda/nvtx.py:2: error: Cannot find implementation or library stub for module named 'torch._C'
torch/utils/show_pickle.py:59: error: Name 'pickle._Unpickler' is not defined
torch/utils/show_pickle.py:113: error: "Type[PrettyPrinter]" has no attribute "_dispatch"
torch/utils/tensorboard/_onnx_graph.py:1: error: Cannot find implementation or library stub for module named 'tensorboard.compat.proto.graph_pb2'
torch/utils/tensorboard/_onnx_graph.py:2: error: Cannot find implementation or library stub for module named 'tensorboard.compat.proto.node_def_pb2'
torch/utils/tensorboard/_onnx_graph.py:3: error: Cannot find implementation or library stub for module named 'tensorboard.compat.proto.versions_pb2'
torch/utils/tensorboard/_onnx_graph.py:4: error: Cannot find implementation or library stub for module named 'tensorboard.compat.proto.attr_value_pb2'
torch/utils/tensorboard/_onnx_graph.py:5: error: Cannot find implementation or library stub for module named 'tensorboard.compat.proto.tensor_shape_pb2'
torch/utils/tensorboard/_onnx_graph.py:9: error: Cannot find implementation or library stub for module named 'onnx'
torch/contrib/_tensorboard_vis.py:10: error: Cannot find implementation or library stub for module named 'tensorflow.core.util'
torch/contrib/_tensorboard_vis.py:11: error: Cannot find implementation or library stub for module named 'tensorflow.core.framework'
torch/contrib/_tensorboard_vis.py:12: error: Cannot find implementation or library stub for module named 'tensorflow.python.summary.writer.writer'
torch/utils/hipify/hipify_python.py:43: error: Need type annotation for 'CAFFE2_TEMPLATE_MAP' (hint: "CAFFE2_TEMPLATE_MAP: Dict[<type>, <type>] = ...")
torch/utils/hipify/hipify_python.py:636: error: "object" has no attribute "items"
torch/nn/_reduction.py:27: error: Name 'Optional' is not defined
torch/nn/_reduction.py:27: note: Did you forget to import it from "typing"? (Suggestion: "from typing import Optional")
torch/nn/_reduction.py:47: error: Name 'Optional' is not defined
torch/nn/_reduction.py:47: note: Did you forget to import it from "typing"? (Suggestion: "from typing import Optional")
torch/utils/tensorboard/_utils.py:17: error: Skipping analyzing 'matplotlib.pyplot': found module but no type hints or library stubs
torch/utils/tensorboard/_utils.py:17: error: Skipping analyzing 'matplotlib': found module but no type hints or library stubs
torch/utils/tensorboard/_utils.py:18: error: Skipping analyzing 'matplotlib.backends.backend_agg': found module but no type hints or library stubs
torch/utils/tensorboard/_utils.py:18: error: Skipping analyzing 'matplotlib.backends': found module but no type hints or library stubs
torch/nn/modules/utils.py:27: error: Name 'List' is not defined
torch/nn/modules/utils.py:27: note: Did you forget to import it from "typing"? (Suggestion: "from typing import List")
caffe2/proto/caffe2_pb2.py:17: error: Unexpected keyword argument "serialized_options" for "FileDescriptor"; did you mean "serialized_pb"?
caffe2/proto/caffe2_pb2.py:25: error: Unexpected keyword argument "serialized_options" for "EnumDescriptor"
caffe2/proto/caffe2_pb2.py:31: error: Unexpected keyword argument "serialized_options" for "EnumValueDescriptor"
caffe2/proto/caffe2_pb2.py:35: error: Unexpected keyword argument "serialized_options" for "EnumValueDescriptor"
caffe2/proto/caffe2_pb2.py:39: error: Unexpected keyword argument "serialized_options" for "EnumValueDescriptor"
caffe2/proto/caffe2_pb2.py:43: error: Unexpected keyword argument "serialized_options" for "EnumValueDescriptor"
caffe2/proto/caffe2_pb2.py:47: error: Unexpected keyword argument "serialized_options" for "EnumValueDescriptor"
caffe2/proto/caffe2_pb2.py:51: error: Unexpected keyword argument "serialized_options" for "EnumValueDescriptor"
caffe2/proto/caffe2_pb2.py:55: error: Unexpected keyword argument "serialized_options" for "EnumValueDescriptor"
caffe2/proto/caffe2_pb2.py:59: error: Unexpected keyword argument "serialized_options" for "EnumValueDescriptor"
caffe2/proto/caffe2_pb2.py:63: error: Unexpected keyword argument "serialized_options" for "EnumValueDescriptor"
caffe2/proto/caffe2_pb2.py:67: error: Unexpected keyword argument "serialized_options" for "EnumValueDescriptor"
caffe2/proto/caffe2_pb2.py:71: error: Unexpected keyword argument "serialized_options" for "EnumValueDescriptor"
caffe2/proto/caffe2_pb2.py:75: error: Unexpected keyword argument "serialized_options" for "EnumValueDescriptor"
caffe2/proto/caffe2_pb2.py:102: error: Unexpected keyword argument "serialized_options" for "EnumDescriptor"
caffe2/proto/caffe2_pb2.py:108: error: Unexpected keyword argument "serialized_options" for "EnumValueDescriptor"
caffe2/proto/caffe2_pb2.py:112: error: Unexpected keyword argument "serialized_options" for "EnumValueDescriptor"
caffe2/proto/caffe2_pb2.py:124: error: Unexpected keyword argument "serialized_options" for "EnumDescriptor"
caffe2/proto/caffe2_pb2.py:130: error: Unexpected keyword argument "serialized_options" for "EnumValueDescriptor"
caffe2/proto/caffe2_pb2.py:134: error: Unexpected keyword argument "serialized_options" for "EnumValueDescriptor"
caffe2/proto/caffe2_pb2.py:138: error: Unexpected keyword argument "serialized_options" for "EnumValueDescriptor"
caffe2/proto/caffe2_pb2.py:142: error: Unexpected keyword argument "serialized_options" for "EnumValueDescriptor"
caffe2/proto/caffe2_pb2.py:146: error: Unexpected keyword argument "serialized_options" for "EnumValueDescriptor"
caffe2/proto/caffe2_pb2.py:150: error: Unexpected keyword argument "serialized_options" for "EnumValueDescriptor"
caffe2/proto/caffe2_pb2.py:154: error: Unexpected keyword argument "serialized_options" for "EnumValueDescriptor"
caffe2/proto/caffe2_pb2.py:158: error: Unexpected keyword argument "serialized_options" for "EnumValueDescriptor"
caffe2/proto/caffe2_pb2.py:162: error: Unexpected keyword argument "serialized_options" for "EnumValueDescriptor"
caffe2/proto/caffe2_pb2.py:166: error: Unexpected keyword argument "serialized_options" for "EnumValueDescriptor"
caffe2/proto/caffe2_pb2.py:170: error: Unexpected keyword argument "serialized_options" for "EnumValueDescriptor"
caffe2/proto/caffe2_pb2.py:174: error: Unexpected keyword argument "serialized_options" for "EnumValueDescriptor"
caffe2/proto/caffe2_pb2.py:178: error: Unexpected keyword argument "serialized_options" for "EnumValueDescriptor"
caffe2/proto/caffe2_pb2.py:182: error: Unexpected keyword argument "serialized_options" for "EnumValueDescriptor"
caffe2/proto/caffe2_pb2.py:194: error: Unexpected keyword argument "serialized_options" for "EnumDescriptor"
caffe2/proto/caffe2_pb2.py:200: error: Unexpected keyword argument "serialized_options" for "EnumValueDescriptor"
caffe2/proto/caffe2_pb2.py:204: error: Unexpected keyword argument "serialized_options" for "EnumValueDescriptor"
caffe2/proto/caffe2_pb2.py:208: error: Unexpected keyword argument "serialized_options" for "EnumValueDescriptor"
caffe2/proto/caffe2_pb2.py:212: error: Unexpected keyword argument "serialized_options" for "EnumValueDescriptor"
caffe2/proto/caffe2_pb2.py:224: error: Unexpected keyword argument "serialized_options" for "EnumDescriptor"
caffe2/proto/caffe2_pb2.py:230: error: Unexpected keyword argument "serialized_options" for "EnumValueDescriptor"
caffe2/proto/caffe2_pb2.py:234: error: Unexpected keyword argument "serialized_options" for "EnumValueDescriptor"
caffe2/proto/caffe2_pb2.py:238: error: Unexpected keyword argument "serialized_options" for "EnumValueDescriptor"
caffe2/proto/caffe2_pb2.py:242: error: Unexpected keyword argument "serialized_options" for "EnumValueDescriptor"
caffe2/proto/caffe2_pb2.py:246: error: Unexpected keyword argument "serialized_options" for "EnumValueDescriptor"
caffe2/proto/caffe2_pb2.py:250: error: Unexpected keyword argument "serialized_options" for "EnumValueDescriptor"
caffe2/proto/caffe2_pb2.py:254: error: Unexpected keyword argument "serialized_options" for "EnumValueDescriptor"
caffe2/proto/caffe2_pb2.py:267: error: Unexpected keyword argument "serialized_options" for "Descriptor"
caffe2/proto/caffe2_pb2.py:274: error: Unexpected keyword argument "serialized_options" for "FieldDescriptor"
caffe2/proto/caffe2_pb2.py:281: error: Unexpected keyword argument "serialized_options" for "FieldDescriptor"
caffe2/proto/caffe2_pb2.py:288: error: Unexpected keyword argument "serialized_options" for "FieldDescriptor"
caffe2/proto/caffe2_pb2.py:295: error: Unexpected keyword argument "serialized_options" for "FieldDescriptor"
caffe2/proto/caffe2_pb2.py:302: error: Unexpected keyword argument "serialized_options" for "FieldDescriptor"
caffe2/proto/caffe2_pb2.py:327: error: Unexpected keyword argument "serialized_options" for "Descriptor"
caffe2/proto/caffe2_pb2.py:334: error: Unexpected keyword argument "serialized_options" for "FieldDescriptor"
caffe2/proto/caffe2_pb2.py:341: error: Unexpected keyword argument "serialized_options" for "FieldDescriptor"
caffe2/proto/caffe2_pb2.py:364: error: Unexpected keyword argument "serialized_options" for "Descriptor"
caffe2/proto/caffe2_pb2.py:371: error: Unexpected keyword argument "serialized_options" for "FieldDescriptor"
caffe2/proto/caffe2_pb2.py:378: error: Unexpected keyword argument "serialized_options" for "FieldDescriptor"
caffe2/proto/caffe2_pb2.py:385: error: Unexpected keyword argument "serialized_options" for "FieldDescriptor"
caffe2/proto/caffe2_pb2.py:392: error: Unexpected keyword argument "serialized_options" for "FieldDescriptor"
caffe2/proto/caffe2_pb2.py:399: error: Unexpected keyword argument "serialized_options" for "FieldDescriptor"
caffe2/proto/caffe2_pb2.py:406: error: Unexpected keyword argument "serialized_options" for "FieldDescriptor"
caffe2/proto/caffe2_pb2.py:413: error: Unexpected keyword argument "serialized_options" for "FieldDescriptor"
caffe2/proto/caffe2_pb2.py:420: error: Unexpected keyword argument "serialized_options" for "FieldDescriptor"
caffe2/proto/caffe2_pb2.py:427: error: Unexpected keyword argument "serialized_options" for "FieldDescriptor"
caffe2/proto/caffe2_pb2.py:434: error: Unexpected keyword argument "serialized_options" for "FieldDescriptor"
caffe2/proto/caffe2_pb2.py:441: error: Unexpected keyword argument "serialized_options" for "FieldDescriptor"
caffe2/proto/caffe2_pb2.py:448: error: Unexpected keyword argument "serialized_options" for "FieldDescriptor"
caffe2/proto/caffe2_pb2.py:455: error: Unexpected keyword argument "serialized_options" for "FieldDescriptor"
caffe2/proto/caffe2_pb2.py:462: error: Unexpected keyword argument "serialized_options" for "FieldDescriptor"
caffe2/proto/caffe2_pb2.py:488: error: Unexpected keyword argument "serialized_options" for "Descriptor"
caffe2/proto/caffe2_pb2.py:495: error: Unexpected keyword argument "serialized_options" for "FieldDescriptor"
caffe2/proto/caffe2_pb2.py:502: error: Unexpected keyword argument "serialized_options" for "FieldDescriptor"
caffe2/proto/caffe2_pb2.py:509: error: Unexpected keyword argument "serialized_options" for "FieldDescriptor"
caffe2/proto/caffe2_pb2.py:516: error: Unexpected keyword argument "serialized_options" for "FieldDescriptor"
caffe2/proto/caffe2_pb2.py:523: error: Unexpected keyword argument "serialized_options" for "FieldDescriptor"
caffe2/proto/caffe2_pb2.py:530: error: Unexpected keyword argument "serialized_options" for "FieldDescriptor"
caffe2/proto/caffe2_pb2.py:537: error: Unexpected keyword argument "serialized_options" for "FieldDescriptor"
caffe2/proto/caffe2_pb2.py:544: error: Unexpected keyword argument "serialized_options" for "FieldDescriptor"
caffe2/proto/caffe2_pb2.py:551: error: Unexpected keyword argument "serialized_options" for "FieldDescriptor"
caffe2/proto/caffe2_pb2.py:558: error: Unexpected keyword argument "serialized_options" for "FieldDescriptor"
caffe2/proto/caffe2_pb2.py:565: error: Unexpected keyword argument "serialized_options" for "FieldDescriptor"
caffe2/proto/caffe2_pb2.py:572: error: Unexpected keyword argument "serialized_options" for "FieldDescriptor"
caffe2/proto/caffe2_pb2.py:596: error: Unexpected keyword argument "serialized_options" for "Descriptor"
caffe2/proto/caffe2_pb2.py:603: error: Unexpected keyword argument "serialized_options" for "FieldDescriptor"
caffe2/proto/caffe2_pb2.py:627: error: Unexpected keyword argument "serialized_options" for "Descriptor"
caffe2/proto/caffe2_pb2.py:634: error: Unexpected keyword argument "serialized_options" for "FieldDescriptor"
caffe2/proto/caffe2_pb2.py:641: error: Unexpected keyword argument "serialized_options" for "FieldDescriptor"
caffe2/proto/caffe2_pb2.py:648: error: Unexpected keyword argument "serialized_options" for "FieldDescriptor"
caffe2/proto/caffe2_pb2.py:655: error: Unexpected keyword argument "serialized_options" for "FieldDescriptor"
caffe2/proto/caffe2_pb2.py:662: error: Unexpected keyword argument "serialized_options" for "FieldDescriptor"
caffe2/proto/caffe2_pb2.py:686: error: Unexpected keyword argument "serialized_options" for "Descriptor"
caffe2/proto/caffe2_pb2.py:693: error: Unexpected keyword argument "serialized_options" for "FieldDescriptor"
caffe2/proto/caffe2_pb2.py:717: error: Unexpected keyword argument "serialized_options" for "Descriptor"
caffe2/proto/caffe2_pb2.py:724: error: Unexpected keyword argument "serialized_options" for "FieldDescriptor"
caffe2/proto/caffe2_pb2.py:731: error: Unexpected keyword argument "serialized_options" for "FieldDescriptor"
caffe2/proto/caffe2_pb2.py:738: error: Unexpected keyword argument "serialized_options" for "FieldDescriptor"
caffe2/proto/caffe2_pb2.py:763: error: Unexpected keyword argument "serialized_options" for "Descriptor"
caffe2/proto/caffe2_pb2.py:770: error: Unexpected keyword argument "serialized_options" for "FieldDescriptor"
caffe2/proto/caffe2_pb2.py:777: error: Unexpected keyword argument "serialized_options" for "FieldDescriptor"
caffe2/proto/caffe2_pb2.py:784: error: Unexpected keyword argument "serialized_options" for "FieldDescriptor"
caffe2/proto/caffe2_pb2.py:808: error: Unexpected keyword argument "serialized_options" for "Descriptor"
caffe2/proto/caffe2_pb2.py:815: error: Unexpected keyword argument "serialized_options" for "FieldDescriptor"
caffe2/proto/caffe2_pb2.py:822: error: Unexpected keyword argument "serialized_options" for "FieldDescriptor"
caffe2/proto/caffe2_pb2.py:829: error: Unexpected keyword argument "serialized_options" for "FieldDescriptor"
caffe2/proto/caffe2_pb2.py:836: error: Unexpected keyword argument "serialized_options" for "FieldDescriptor"
caffe2/proto/caffe2_pb2.py:843: error: Unexpected keyword argument "serialized_options" for "FieldDescriptor"
caffe2/proto/caffe2_pb2.py:850: error: Unexpected keyword argument "serialized_options" for "FieldDescriptor"
caffe2/proto/caffe2_pb2.py:857: error: Unexpected keyword argument "serialized_options" for "FieldDescriptor"
caffe2/proto/caffe2_pb2.py:864: error: Unexpected keyword argument "serialized_options" for "FieldDescriptor"
caffe2/proto/caffe2_pb2.py:871: error: Unexpected keyword argument "serialized_options" for "FieldDescriptor"
caffe2/proto/caffe2_pb2.py:878: error: Unexpected keyword argument "serialized_options" for "FieldDescriptor"
caffe2/proto/caffe2_pb2.py:885: error: Unexpected keyword argument "serialized_options" for "FieldDescriptor"
caffe2/proto/caffe2_pb2.py:892: error: Unexpected keyword argument "serialized_options" for "FieldDescriptor"
caffe2/proto/caffe2_pb2.py:916: error: Unexpected keyword argument "serialized_options" for "Descriptor"
caffe2/proto/caffe2_pb2.py:923: error: Unexpected keyword argument "serialized_options" for "FieldDescriptor"
caffe2/proto/caffe2_pb2.py:930: error: Unexpected keyword argument "serialized_options" for "FieldDescriptor"
caffe2/proto/caffe2_pb2.py:937: error: Unexpected keyword argument "serialized_options" for "FieldDescriptor"
caffe2/proto/caffe2_pb2.py:944: error: Unexpected keyword argument "serialized_options" for "FieldDescriptor"
caffe2/proto/caffe2_pb2.py:951: error: Unexpected keyword argument "serialized_options" for "FieldDescriptor"
caffe2/proto/caffe2_pb2.py:958: error: Unexpected keyword argument "serialized_options" for "FieldDescriptor"
caffe2/proto/caffe2_pb2.py:982: error: Unexpected keyword argument "serialized_options" for "Descriptor"
caffe2/proto/caffe2_pb2.py:989: error: Unexpected keyword argument "serialized_options" for "FieldDescriptor"
caffe2/proto/caffe2_pb2.py:996: error: Unexpected keyword argument "serialized_options" for "FieldDescriptor"
caffe2/proto/caffe2_pb2.py:1003: error: Unexpected keyword argument "serialized_options" for "FieldDescriptor"
caffe2/proto/caffe2_pb2.py:1010: error: Unexpected keyword argument "serialized_options" for "FieldDescriptor"
caffe2/proto/caffe2_pb2.py:1017: error: Unexpected keyword argument "serialized_options" for "FieldDescriptor"
caffe2/proto/caffe2_pb2.py:1024: error: Unexpected keyword argument "serialized_options" for "FieldDescriptor"
caffe2/proto/caffe2_pb2.py:1031: error: Unexpected keyword argument "serialized_options" for "FieldDescriptor"
caffe2/proto/caffe2_pb2.py:1038: error: Unexpected keyword argument "serialized_options" for "FieldDescriptor"
caffe2/proto/caffe2_pb2.py:1045: error: Unexpected keyword argument "serialized_options" for "FieldDescriptor"
caffe2/proto/caffe2_pb2.py:1052: error: Unexpected keyword argument "serialized_options" for "FieldDescriptor"
caffe2/proto/caffe2_pb2.py:1059: error: Unexpected keyword argument "serialized_options" for "FieldDescriptor"
caffe2/proto/caffe2_pb2.py:1066: error: Unexpected keyword argument "serialized_options" for "FieldDescriptor"
caffe2/proto/caffe2_pb2.py:1090: error: Unexpected keyword argument "serialized_options" for "Descriptor"
caffe2/proto/caffe2_pb2.py:1097: error: Unexpected keyword argument "serialized_options" for "FieldDescriptor"
caffe2/proto/caffe2_pb2.py:1104: error: Unexpected keyword argument "serialized_options" for "FieldDescriptor"
caffe2/proto/caffe2_pb2.py:1128: error: Unexpected keyword argument "serialized_options" for "Descriptor"
caffe2/proto/caffe2_pb2.py:1135: error: Unexpected keyword argument "serialized_options" for "FieldDescriptor"
caffe2/proto/caffe2_pb2.py:1142: error: Unexpected keyword argument "serialized_options" for "FieldDescriptor"
caffe2/proto/caffe2_pb2.py:1166: error: Unexpected keyword argument "serialized_options" for "Descriptor"
caffe2/proto/caffe2_pb2.py:1173: error: Unexpected keyword argument "serialized_options" for "FieldDescriptor"
caffe2/proto/caffe2_pb2.py:1180: error: Unexpected keyword argument "serialized_options" for "FieldDescriptor"
caffe2/proto/caffe2_pb2.py:1187: error: Unexpected keyword argument "serialized_options" for "FieldDescriptor"
caffe2/proto/caffe2_pb2.py:1194: error: Unexpected keyword argument "serialized_options" for "FieldDescriptor"
caffe2/proto/caffe2_pb2.py:1218: error: Unexpected keyword argument "serialized_options" for "Descriptor"
caffe2/proto/caffe2_pb2.py:1225: error: Unexpected keyword argument "serialized_options" for "FieldDescriptor"
caffe2/proto/caffe2_pb2.py:1232: error: Unexpected keyword argument "serialized_options" for "FieldDescriptor"
caffe2/proto/caffe2_pb2.py:1239: error: Unexpected keyword argument "serialized_options" for "FieldDescriptor"
caffe2/proto/caffe2_pb2.py:1246: error: Unexpected keyword argument "serialized_options" for "FieldDescriptor"
caffe2/proto/caffe2_pb2.py:1253: error: Unexpected keyword argument "serialized_options" for "FieldDescriptor"
caffe2/proto/caffe2_pb2.py:1260: error: Unexpected keyword argument "serialized_options" for "FieldDescriptor"
caffe2/proto/caffe2_pb2.py:1267: error: Unexpected keyword argument "serialized_options" for "FieldDescriptor"
caffe2/proto/caffe2_pb2.py:1274: error: Unexpected keyword argument "serialized_options" for "FieldDescriptor"
caffe2/proto/caffe2_pb2.py:1281: error: Unexpected keyword argument "serialized_options" for "FieldDescriptor"
caffe2/proto/caffe2_pb2.py:1305: error: Unexpected keyword argument "serialized_options" for "Descriptor"
caffe2/proto/caffe2_pb2.py:1312: error: Unexpected keyword argument "serialized_options" for "FieldDescriptor"
caffe2/proto/caffe2_pb2.py:1319: error: Unexpected keyword argument "serialized_options" for "FieldDescriptor"
caffe2/proto/caffe2_pb2.py:1326: error: Unexpected keyword argument "serialized_options" for "FieldDescriptor"
caffe2/proto/caffe2_pb2.py:1333: error: Unexpected keyword argument "serialized_options" for "FieldDescriptor"
caffe2/proto/caffe2_pb2.py:1340: error: Unexpected keyword argument "serialized_options" for "FieldDescriptor"
caffe2/proto/caffe2_pb2.py:1347: error: Unexpected keyword argument "serialized_options" for "FieldDescriptor"
caffe2/proto/caffe2_pb2.py:1354: error: Unexpected keyword argument "serialized_options" for "FieldDescriptor"
caffe2/proto/caffe2_pb2.py:1361: error: Unexpected keyword argument "serialized_options" for "FieldDescriptor"
caffe2/proto/caffe2_pb2.py:1368: error: Unexpected keyword argument "serialized_options" for "FieldDescriptor"
caffe2/proto/caffe2_pb2.py:1375: error: Unexpected keyword argument "serialized_options" for "FieldDescriptor"
caffe2/proto/caffe2_pb2.py:1382: error: Unexpected keyword argument "serialized_options" for "FieldDescriptor"
caffe2/proto/caffe2_pb2.py:1389: error: Unexpected keyword argument "serialized_options" for "FieldDescriptor"
caffe2/proto/caffe2_pb2.py:1396: error: Unexpected keyword argument "serialized_options" for "FieldDescriptor"
caffe2/proto/caffe2_pb2.py:1420: error: Unexpected keyword argument "serialized_options" for "Descriptor"
caffe2/proto/caffe2_pb2.py:1427: error: Unexpected keyword argument "serialized_options" for "FieldDescriptor"
caffe2/proto/caffe2_pb2.py:1434: error: Unexpected keyword argument "serialized_options" for "FieldDescriptor"
caffe2/proto/caffe2_pb2.py:1441: error: Unexpected keyword argument "serialized_options" for "FieldDescriptor"
caffe2/proto/caffe2_pb2.py:1465: error: Unexpected keyword argument "serialized_options" for "Descriptor"
caffe2/proto/caffe2_pb2.py:1472: error: Unexpected keyword argument "serialized_options" for "FieldDescriptor"
caffe2/proto/caffe2_pb2.py:1479: error: Unexpected keyword argument "serialized_options" for "FieldDescriptor"
caffe2/proto/caffe2_pb2.py:1486: error: Unexpected keyword argument "serialized_options" for "FieldDescriptor"
caffe2/proto/caffe2_pb2.py:1493: error: Unexpected keyword argument "serialized_options" for "FieldDescriptor"
caffe2/proto/caffe2_pb2.py:1500: error: Unexpected keyword argument "serialized_options" for "FieldDescriptor"
caffe2/proto/caffe2_pb2.py:1507: error: Unexpected keyword argument "serialized_options" for "FieldDescriptor"
caffe2/proto/caffe2_pb2.py:1514: error: Unexpected keyword argument "serialized_options" for "FieldDescriptor"
caffe2/proto/caffe2_pb2.py:1538: error: Unexpected keyword argument "serialized_options" for "Descriptor"
caffe2/proto/caffe2_pb2.py:1545: error: Unexpected keyword argument "serialized_options" for "FieldDescriptor"
caffe2/proto/caffe2_pb2.py:1552: error: Unexpected keyword argument "serialized_options" for "FieldDescriptor"
caffe2/proto/caffe2_pb2.py:1559: error: Unexpected keyword argument "serialized_options" for "FieldDescriptor"
caffe2/proto/caffe2_pb2.py:1566: error: Unexpected keyword argument "serialized_options" for "FieldDescriptor"
caffe2/proto/caffe2_pb2.py:1667: error: "GeneratedProtocolMessageType" has no attribute "Segment"
torch/multiprocessing/queue.py:4: error: No library stub file for standard library module 'multiprocessing.reduction'
caffe2/proto/torch_pb2.py:18: error: Unexpected keyword argument "serialized_options" for "FileDescriptor"; did you mean "serialized_pb"?
caffe2/proto/torch_pb2.py:27: error: Unexpected keyword argument "serialized_options" for "EnumDescriptor"
caffe2/proto/torch_pb2.py:33: error: Unexpected keyword argument "serialized_options" for "EnumValueDescriptor"
caffe2/proto/torch_pb2.py:50: error: Unexpected keyword argument "serialized_options" for "Descriptor"
caffe2/proto/torch_pb2.py:57: error: Unexpected keyword argument "serialized_options" for "FieldDescriptor"
caffe2/proto/torch_pb2.py:81: error: Unexpected keyword argument "serialized_options" for "Descriptor"
caffe2/proto/torch_pb2.py:88: error: Unexpected keyword argument "serialized_options" for "FieldDescriptor"
caffe2/proto/torch_pb2.py:95: error: Unexpected keyword argument "serialized_options" for "FieldDescriptor"
caffe2/proto/torch_pb2.py:102: error: Unexpected keyword argument "serialized_options" for "FieldDescriptor"
caffe2/proto/torch_pb2.py:109: error: Unexpected keyword argument "serialized_options" for "FieldDescriptor"
caffe2/proto/torch_pb2.py:116: error: Unexpected keyword argument "serialized_options" for "FieldDescriptor"
caffe2/proto/torch_pb2.py:123: error: Unexpected keyword argument "serialized_options" for "FieldDescriptor"
caffe2/proto/torch_pb2.py:130: error: Unexpected keyword argument "serialized_options" for "FieldDescriptor"
caffe2/proto/torch_pb2.py:137: error: Unexpected keyword argument "serialized_options" for "FieldDescriptor"
caffe2/proto/torch_pb2.py:144: error: Unexpected keyword argument "serialized_options" for "FieldDescriptor"
caffe2/proto/torch_pb2.py:151: error: Unexpected keyword argument "serialized_options" for "FieldDescriptor"
caffe2/proto/torch_pb2.py:175: error: Unexpected keyword argument "serialized_options" for "Descriptor"
caffe2/proto/torch_pb2.py:182: error: Unexpected keyword argument "serialized_options" for "FieldDescriptor"
caffe2/proto/torch_pb2.py:189: error: Unexpected keyword argument "serialized_options" for "FieldDescriptor"
caffe2/proto/torch_pb2.py:196: error: Unexpected keyword argument "serialized_options" for "FieldDescriptor"
caffe2/proto/torch_pb2.py:220: error: Unexpected keyword argument "serialized_options" for "Descriptor"
caffe2/proto/torch_pb2.py:227: error: Unexpected keyword argument "serialized_options" for "FieldDescriptor"
caffe2/proto/torch_pb2.py:234: error: Unexpected keyword argument "serialized_options" for "FieldDescriptor"
caffe2/proto/torch_pb2.py:241: error: Unexpected keyword argument "serialized_options" for "FieldDescriptor"
caffe2/proto/torch_pb2.py:265: error: Unexpected keyword argument "serialized_options" for "Descriptor"
caffe2/proto/torch_pb2.py:272: error: Unexpected keyword argument "serialized_options" for "FieldDescriptor"
caffe2/proto/torch_pb2.py:279: error: Unexpected keyword argument "serialized_options" for "FieldDescriptor"
caffe2/proto/torch_pb2.py:286: error: Unexpected keyword argument "serialized_options" for "FieldDescriptor"
caffe2/proto/torch_pb2.py:293: error: Unexpected keyword argument "serialized_options" for "FieldDescriptor"
caffe2/proto/torch_pb2.py:300: error: Unexpected keyword argument "serialized_options" for "FieldDescriptor"
caffe2/proto/torch_pb2.py:307: error: Unexpected keyword argument "serialized_options" for "FieldDescriptor"
caffe2/proto/torch_pb2.py:314: error: Unexpected keyword argument "serialized_options" for "FieldDescriptor"
caffe2/proto/torch_pb2.py:321: error: Unexpected keyword argument "serialized_options" for "FieldDescriptor"
caffe2/proto/torch_pb2.py:328: error: Unexpected keyword argument "serialized_options" for "FieldDescriptor"
caffe2/proto/torch_pb2.py:335: error: Unexpected keyword argument "serialized_options" for "FieldDescriptor"
caffe2/proto/torch_pb2.py:342: error: Unexpected keyword argument "serialized_options" for "FieldDescriptor"
caffe2/proto/torch_pb2.py:366: error: Unexpected keyword argument "serialized_options" for "Descriptor"
caffe2/proto/torch_pb2.py:373: error: Unexpected keyword argument "serialized_options" for "FieldDescriptor"
caffe2/proto/torch_pb2.py:397: error: Unexpected keyword argument "serialized_options" for "Descriptor"
caffe2/proto/torch_pb2.py:404: error: Unexpected keyword argument "serialized_options" for "FieldDescriptor"
caffe2/proto/torch_pb2.py:411: error: Unexpected keyword argument "serialized_options" for "FieldDescriptor"
caffe2/proto/torch_pb2.py:418: error: Unexpected keyword argument "serialized_options" for "FieldDescriptor"
caffe2/proto/torch_pb2.py:425: error: Unexpected keyword argument "serialized_options" for "FieldDescriptor"
caffe2/proto/torch_pb2.py:432: error: Unexpected keyword argument "serialized_options" for "FieldDescriptor"
caffe2/proto/metanet_pb2.py:17: error: Unexpected keyword argument "serialized_options" for "FileDescriptor"; did you mean "serialized_pb"?
caffe2/proto/metanet_pb2.py:29: error: Unexpected keyword argument "serialized_options" for "Descriptor"
caffe2/proto/metanet_pb2.py:36: error: Unexpected keyword argument "serialized_options" for "FieldDescriptor"
caffe2/proto/metanet_pb2.py:43: error: Unexpected keyword argument "serialized_options" for "FieldDescriptor"
caffe2/proto/metanet_pb2.py:50: error: Unexpected keyword argument "serialized_options" for "FieldDescriptor"
caffe2/proto/metanet_pb2.py:57: error: Unexpected keyword argument "serialized_options" for "FieldDescriptor"
caffe2/proto/metanet_pb2.py:64: error: Unexpected keyword argument "serialized_options" for "FieldDescriptor"
caffe2/proto/metanet_pb2.py:88: error: Unexpected keyword argument "serialized_options" for "Descriptor"
caffe2/proto/metanet_pb2.py:95: error: Unexpected keyword argument "serialized_options" for "FieldDescriptor"
caffe2/proto/metanet_pb2.py:102: error: Unexpected keyword argument "serialized_options" for "FieldDescriptor"
caffe2/proto/metanet_pb2.py:126: error: Unexpected keyword argument "serialized_options" for "Descriptor"
caffe2/proto/metanet_pb2.py:133: error: Unexpected keyword argument "serialized_options" for "FieldDescriptor"
caffe2/proto/metanet_pb2.py:140: error: Unexpected keyword argument "serialized_options" for "FieldDescriptor"
caffe2/proto/metanet_pb2.py:164: error: Unexpected keyword argument "serialized_options" for "Descriptor"
caffe2/proto/metanet_pb2.py:171: error: Unexpected keyword argument "serialized_options" for "FieldDescriptor"
caffe2/proto/metanet_pb2.py:178: error: Unexpected keyword argument "serialized_options" for "FieldDescriptor"
caffe2/proto/metanet_pb2.py:202: error: Unexpected keyword argument "serialized_options" for "Descriptor"
caffe2/proto/metanet_pb2.py:209: error: Unexpected keyword argument "serialized_options" for "FieldDescriptor"
caffe2/proto/metanet_pb2.py:216: error: Unexpected keyword argument "serialized_options" for "FieldDescriptor"
caffe2/proto/metanet_pb2.py:240: error: Unexpected keyword argument "serialized_options" for "Descriptor"
caffe2/proto/metanet_pb2.py:247: error: Unexpected keyword argument "serialized_options" for "FieldDescriptor"
caffe2/proto/metanet_pb2.py:254: error: Unexpected keyword argument "serialized_options" for "FieldDescriptor"
caffe2/proto/metanet_pb2.py:261: error: Unexpected keyword argument "serialized_options" for "FieldDescriptor"
caffe2/proto/metanet_pb2.py:268: error: Unexpected keyword argument "serialized_options" for "FieldDescriptor"
caffe2/proto/metanet_pb2.py:275: error: Unexpected keyword argument "serialized_options" for "FieldDescriptor"
caffe2/proto/metanet_pb2.py:282: error: Unexpected keyword argument "serialized_options" for "FieldDescriptor"
caffe2/proto/metanet_pb2.py:289: error: Unexpected keyword argument "serialized_options" for "FieldDescriptor"
caffe2/proto/metanet_pb2.py:296: error: Unexpected keyword argument "serialized_options" for "FieldDescriptor"
caffe2/proto/__init__.py:13: error: Skipping analyzing 'caffe2.caffe2.fb.session.proto': found module but no type hints or library stubs
torch/multiprocessing/pool.py:3: error: No library stub file for standard library module 'multiprocessing.util'
torch/multiprocessing/pool.py:3: note: (Stub files are from https://github.com/python/typeshed)
caffe2/python/scope.py:10: error: Skipping analyzing 'past.builtins': found module but no type hints or library stubs
caffe2/python/__init__.py:7: error: Module has no attribute "CPU"
caffe2/python/__init__.py:8: error: Module has no attribute "CUDA"
caffe2/python/__init__.py:9: error: Module has no attribute "MKLDNN"
caffe2/python/__init__.py:10: error: Module has no attribute "OPENGL"
caffe2/python/__init__.py:11: error: Module has no attribute "OPENCL"
caffe2/python/__init__.py:12: error: Module has no attribute "IDEEP"
caffe2/python/__init__.py:13: error: Module has no attribute "HIP"
caffe2/python/__init__.py:14: error: Module has no attribute "COMPILE_TIME_MAX_DEVICE_TYPES"; maybe "PROTO_COMPILE_TIME_MAX_DEVICE_TYPES"?
caffe2/python/__init__.py:15: error: Module has no attribute "ONLY_FOR_TEST"; maybe "PROTO_ONLY_FOR_TEST"?
caffe2/python/__init__.py:34: error: Item "_Loader" of "Optional[_Loader]" has no attribute "exec_module"
caffe2/python/__init__.py:34: error: Item "None" of "Optional[_Loader]" has no attribute "exec_module"
caffe2/python/__init__.py:35: error: Module has no attribute "cuda"
caffe2/python/__init__.py:37: error: Module has no attribute "cuda"
caffe2/python/__init__.py:49: error: Module has no attribute "add_dll_directory"
torch/random.py:4: error: Cannot find implementation or library stub for module named 'torch._C'
torch/_classes.py:2: error: Cannot find implementation or library stub for module named 'torch._C'
torch/onnx/__init__.py:1: error: Cannot find implementation or library stub for module named 'torch._C'
torch/hub.py:21: error: Skipping analyzing 'tqdm.auto': found module but no type hints or library stubs
torch/hub.py:24: error: Skipping analyzing 'tqdm': found module but no type hints or library stubs
torch/hub.py:27: error: Name 'tqdm' already defined (possibly by an import)
torch/_tensor_str.py:164: error: Not all arguments converted during string formatting
torch/_ops.py:1: error: Cannot find implementation or library stub for module named 'torch._C'
torch/_linalg_utils.py:26: error: Name 'Optional' is not defined
torch/_linalg_utils.py:26: note: Did you forget to import it from "typing"? (Suggestion: "from typing import Optional")
torch/_linalg_utils.py:26: error: Name 'Tensor' is not defined
torch/_linalg_utils.py:63: error: Name 'Tensor' is not defined
torch/_linalg_utils.py:63: error: Name 'Optional' is not defined
torch/_linalg_utils.py:63: note: Did you forget to import it from "typing"? (Suggestion: "from typing import Optional")
torch/_linalg_utils.py:70: error: Name 'Optional' is not defined
torch/_linalg_utils.py:70: note: Did you forget to import it from "typing"? (Suggestion: "from typing import Optional")
torch/_linalg_utils.py:70: error: Name 'Tensor' is not defined
torch/_linalg_utils.py:88: error: Name 'Tensor' is not defined
torch/_linalg_utils.py:88: error: Name 'Optional' is not defined
torch/_linalg_utils.py:88: note: Did you forget to import it from "typing"? (Suggestion: "from typing import Optional")
torch/_linalg_utils.py:88: error: Name 'Tuple' is not defined
torch/_linalg_utils.py:88: note: Did you forget to import it from "typing"? (Suggestion: "from typing import Tuple")
torch/_jit_internal.py:17: error: Need type annotation for 'boolean_dispatched'
torch/_jit_internal.py:474: error: Need type annotation for '_overloaded_fns' (hint: "_overloaded_fns: Dict[<type>, <type>] = ...")
torch/_jit_internal.py:512: error: Need type annotation for '_overloaded_methods' (hint: "_overloaded_methods: Dict[<type>, <type>] = ...")
torch/_jit_internal.py:648: error: Incompatible types in assignment (expression has type "FinalCls", variable has type "_SpecialForm")
torch/sparse/__init__.py:11: error: Name 'Tensor' is not defined
torch/sparse/__init__.py:71: error: Name 'Tensor' is not defined
torch/sparse/__init__.py:71: error: Name 'Optional' is not defined
torch/sparse/__init__.py:71: note: Did you forget to import it from "typing"? (Suggestion: "from typing import Optional")
torch/sparse/__init__.py:71: error: Name 'Tuple' is not defined
torch/sparse/__init__.py:71: note: Did you forget to import it from "typing"? (Suggestion: "from typing import Tuple")
torch/nn/init.py:109: error: Name 'Tensor' is not defined
torch/nn/init.py:126: error: Name 'Tensor' is not defined
torch/nn/init.py:142: error: Name 'Tensor' is not defined
torch/nn/init.py:165: error: Name 'Tensor' is not defined
torch/nn/init.py:180: error: Name 'Tensor' is not defined
torch/nn/init.py:194: error: Name 'Tensor' is not defined
torch/nn/init.py:287: error: Name 'Tensor' is not defined
torch/nn/init.py:315: error: Name 'Tensor' is not defined
torch/multiprocessing/reductions.py:8: error: No library stub file for standard library module 'multiprocessing.util'
torch/multiprocessing/reductions.py:9: error: No library stub file for standard library module 'multiprocessing.reduction'
torch/multiprocessing/reductions.py:17: error: No library stub file for standard library module 'multiprocessing.resource_sharer'
torch/jit/_builtins.py:72: error: Module has no attribute "_no_grad_embedding_renorm_"
torch/jit/_builtins.py:80: error: Module has no attribute "stft"
torch/jit/_builtins.py:81: error: Module has no attribute "cdist"
torch/jit/_builtins.py:82: error: Module has no attribute "norm"
torch/jit/_builtins.py:83: error: Module has no attribute "nuclear_norm"
torch/jit/_builtins.py:84: error: Module has no attribute "frobenius_norm"
torch/backends/cudnn/__init__.py:8: error: Cannot find implementation or library stub for module named 'torch._C'
torch/backends/cudnn/__init__.py:86: error: Need type annotation for '_handles' (hint: "_handles: Dict[<type>, <type>] = ...")
torch/autograd/profiler.py:13: error: Name 'ContextDecorator' already defined (possibly by an import)
torch/autograd/function.py:2: error: Cannot find implementation or library stub for module named 'torch._C'
torch/autograd/function.py:2: note: See https://mypy.readthedocs.io/en/latest/running_mypy.html#missing-imports
torch/autograd/function.py:109: error: Unsupported dynamic base class "with_metaclass"
torch/serialization.py:609: error: "Callable[[Any], Any]" has no attribute "cache"
torch/_lowrank.py:11: error: Name 'Tensor' is not defined
torch/_lowrank.py:13: error: Name 'Optional' is not defined
torch/_lowrank.py:13: note: Did you forget to import it from "typing"? (Suggestion: "from typing import Optional")
torch/_lowrank.py:14: error: Name 'Optional' is not defined
torch/_lowrank.py:14: note: Did you forget to import it from "typing"? (Suggestion: "from typing import Optional")
torch/_lowrank.py:14: error: Name 'Tensor' is not defined
torch/_lowrank.py:82: error: Name 'Tensor' is not defined
torch/_lowrank.py:82: error: Name 'Optional' is not defined
torch/_lowrank.py:82: note: Did you forget to import it from "typing"? (Suggestion: "from typing import Optional")
torch/_lowrank.py:82: error: Name 'Tuple' is not defined
torch/_lowrank.py:82: note: Did you forget to import it from "typing"? (Suggestion: "from typing import Tuple")
torch/_lowrank.py:130: error: Name 'Tensor' is not defined
torch/_lowrank.py:130: error: Name 'Optional' is not defined
torch/_lowrank.py:130: note: Did you forget to import it from "typing"? (Suggestion: "from typing import Optional")
torch/_lowrank.py:130: error: Name 'Tuple' is not defined
torch/_lowrank.py:130: note: Did you forget to import it from "typing"? (Suggestion: "from typing import Tuple")
torch/_lowrank.py:167: error: Name 'Tensor' is not defined
torch/_lowrank.py:167: error: Name 'Optional' is not defined
torch/_lowrank.py:167: note: Did you forget to import it from "typing"? (Suggestion: "from typing import Optional")
torch/_lowrank.py:167: error: Name 'Tuple' is not defined
torch/_lowrank.py:167: note: Did you forget to import it from "typing"? (Suggestion: "from typing import Tuple")
torch/quantization/observer.py:45: error: Variable "torch.quantization.observer.ABC" is not valid as a type
torch/quantization/observer.py:45: note: See https://mypy.readthedocs.io/en/latest/common_issues.html#variables-vs-type-aliases
torch/quantization/observer.py:45: error: Invalid base class "ABC"
torch/quantization/observer.py:127: error: Name 'Tensor' is not defined
torch/quantization/observer.py:127: error: Name 'Tuple' is not defined
torch/quantization/observer.py:127: note: Did you forget to import it from "typing"? (Suggestion: "from typing import Tuple")
torch/quantization/observer.py:172: error: Module has no attribute "per_tensor_symmetric"
torch/quantization/observer.py:172: error: Module has no attribute "per_channel_symmetric"
torch/quantization/observer.py:192: error: Name 'Tensor' is not defined
torch/quantization/observer.py:192: error: Name 'Tuple' is not defined
torch/quantization/observer.py:192: note: Did you forget to import it from "typing"? (Suggestion: "from typing import Tuple")
torch/quantization/observer.py:233: error: Module has no attribute "per_tensor_symmetric"
torch/quantization/observer.py:233: error: Module has no attribute "per_channel_symmetric"
torch/quantization/observer.py:534: error: Name 'Tensor' is not defined
torch/quantization/observer.py:885: error: Name 'Tensor' is not defined
torch/quantization/observer.py:885: error: Name 'Tuple' is not defined
torch/quantization/observer.py:885: note: Did you forget to import it from "typing"? (Suggestion: "from typing import Tuple")
torch/quantization/observer.py:894: error: Cannot determine type of 'max_val'
torch/quantization/observer.py:894: error: Cannot determine type of 'min_val'
torch/quantization/observer.py:899: error: Cannot determine type of 'min_val'
torch/quantization/observer.py:902: error: Name 'Tensor' is not defined
torch/quantization/observer.py:925: error: Name 'Tensor' is not defined
torch/quantization/observer.py:928: error: Cannot determine type of 'min_val'
torch/quantization/observer.py:929: error: Cannot determine type of 'max_val'
torch/quantization/observer.py:946: error: Argument "min" to "histc" has incompatible type "Tuple[Tensor, Tensor]"; expected "Union[int, float, bool]"
torch/quantization/observer.py:946: error: Argument "max" to "histc" has incompatible type "Tuple[Tensor, Tensor]"; expected "Union[int, float, bool]"
torch/quantization/observer.py:1056: error: Module has no attribute "per_tensor_symmetric"
torch/quantization/observer.py:1058: error: Module has no attribute "per_channel_symmetric"
torch/nn/quantized/functional.py:76: error: Name 'Tensor' is not defined
torch/nn/quantized/functional.py:76: error: Name 'BroadcastingList2' is not defined
torch/nn/quantized/functional.py:259: error: Name 'Tensor' is not defined
torch/nn/quantized/functional.py:259: error: Name 'Optional' is not defined
torch/nn/quantized/functional.py:259: note: Did you forget to import it from "typing"? (Suggestion: "from typing import Optional")
torch/nn/quantized/functional.py:289: error: Module has no attribute "ops"
torch/nn/quantized/functional.py:290: error: Module has no attribute "ops"
torch/nn/quantized/functional.py:308: error: Name 'Tensor' is not defined
torch/nn/quantized/functional.py:326: error: Name 'Tensor' is not defined
torch/nn/quantized/functional.py:356: error: Name 'Tensor' is not defined
torch/nn/quantized/functional.py:371: error: Name 'Tensor' is not defined
torch/nn/quantized/functional.py:400: error: Name 'Tensor' is not defined
torch/nn/quantized/functional.py:400: error: Name 'Optional' is not defined
torch/nn/quantized/functional.py:400: note: Did you forget to import it from "typing"? (Suggestion: "from typing import Optional")
torch/nn/quantized/functional.py:430: error: Name 'Tensor' is not defined
torch/nn/quantized/functional.py:448: error: Name 'Tensor' is not defined
torch/nn/quantized/modules/linear.py:26: error: Module has no attribute "ops"
torch/nn/quantized/modules/linear.py:28: error: Module has no attribute "ops"
torch/nn/quantized/modules/functional_modules.py:40: error: Name 'Tensor' is not defined
torch/nn/quantized/modules/functional_modules.py:47: error: Name 'Tensor' is not defined
torch/nn/quantized/modules/functional_modules.py:54: error: Name 'Tensor' is not defined
torch/nn/quantized/modules/functional_modules.py:61: error: Name 'Tensor' is not defined
torch/nn/quantized/modules/functional_modules.py:68: error: Name 'List' is not defined
torch/nn/quantized/modules/functional_modules.py:68: note: Did you forget to import it from "typing"? (Suggestion: "from typing import List")
torch/nn/quantized/modules/functional_modules.py:68: error: Name 'Tensor' is not defined
torch/nn/quantized/modules/functional_modules.py:75: error: Name 'Tensor' is not defined
torch/nn/quantized/modules/functional_modules.py:140: error: Name 'Tensor' is not defined
torch/nn/quantized/modules/functional_modules.py:146: error: Name 'Tensor' is not defined
torch/nn/quantized/modules/functional_modules.py:151: error: Name 'Tensor' is not defined
torch/nn/quantized/modules/functional_modules.py:157: error: Name 'Tensor' is not defined
torch/nn/quantized/modules/functional_modules.py:162: error: Name 'List' is not defined
torch/nn/quantized/modules/functional_modules.py:162: note: Did you forget to import it from "typing"? (Suggestion: "from typing import List")
torch/nn/quantized/modules/functional_modules.py:162: error: Name 'Tensor' is not defined
torch/nn/quantized/modules/functional_modules.py:168: error: Name 'Tensor' is not defined
torch/multiprocessing/spawn.py:9: error: Module 'torch.multiprocessing' has no attribute '_prctl_pr_set_pdeathsig'
torch/multiprocessing/__init__.py:28: error: Module has no attribute "__all__"
torch/jit/frontend.py:9: error: Cannot find implementation or library stub for module named 'torch._C._jit_tree_views'
torch/jit/annotations.py:6: error: Module 'torch._jit_internal' has no attribute 'BroadcastingList2'; maybe "BroadcastingList1" or "BroadcastingListCls"?
torch/jit/annotations.py:6: error: Module 'torch._jit_internal' has no attribute 'BroadcastingList3'; maybe "BroadcastingList1" or "BroadcastingListCls"?
torch/jit/annotations.py:9: error: Cannot find implementation or library stub for module named 'torch._C'
torch/distributions/distribution.py:16: error: Need type annotation for 'arg_constraints' (hint: "arg_constraints: Dict[<type>, <type>] = ...")
torch/distributions/distribution.py:74: error: Name 'arg_constraints' already defined on line 16
torch/distributions/distribution.py:84: error: Name 'support' already defined on line 15
torch/functional.py:114: error: Name 'Tuple' is not defined
torch/functional.py:114: note: Did you forget to import it from "typing"? (Suggestion: "from typing import Tuple")
torch/functional.py:114: error: Name 'Optional' is not defined
torch/functional.py:114: note: Did you forget to import it from "typing"? (Suggestion: "from typing import Optional")
torch/functional.py:189: error: Incompatible types in assignment (expression has type "None", variable has type "Tensor")
torch/functional.py:200: error: Argument 1 to "_indices_product" has incompatible type "Tuple[int, ...]"; expected "List[int]"
torch/functional.py:204: error: No overload variant of "__setitem__" of "list" matches argument types "Tensor", "int"
torch/functional.py:204: note: Possible overload variants:
torch/functional.py:204: note:     def __setitem__(self, int, int) -> None
torch/functional.py:204: note:     def __setitem__(self, slice, Iterable[int]) -> None
torch/functional.py:204: error: No overload variant of "__getitem__" of "list" matches argument type "Tensor"
torch/functional.py:204: note:     def __getitem__(self, int) -> int
torch/functional.py:204: note:     def __getitem__(self, slice) -> List[int]
torch/functional.py:207: error: "Tensor" has no attribute "copy_"
torch/functional.py:212: error: No overload variant of "__setitem__" of "list" matches argument types "Tensor", "int"
torch/functional.py:212: note: Possible overload variants:
torch/functional.py:212: note:     def __setitem__(self, int, int) -> None
torch/functional.py:212: note:     def __setitem__(self, slice, Iterable[int]) -> None
torch/functional.py:212: error: No overload variant of "__getitem__" of "list" matches argument type "Tensor"
torch/functional.py:212: note:     def __getitem__(self, int) -> int
torch/functional.py:212: note:     def __getitem__(self, slice) -> List[int]
torch/functional.py:215: error: Incompatible types in assignment (expression has type "None", variable has type "Tensor")
torch/functional.py:334: error: Name 'Optional' is not defined
torch/functional.py:334: note: Did you forget to import it from "typing"? (Suggestion: "from typing import Optional")
torch/functional.py:429: error: Argument 2 to "pad" has incompatible type "Tuple[int, int]"; expected "List[int]"
torch/functional.py:431: error: Module has no attribute "stft"
torch/functional.py:766: error: Module has no attribute "cdist"
torch/functional.py:768: error: Module has no attribute "cdist"
torch/functional.py:770: error: Module has no attribute "cdist"
torch/functional.py:775: error: Name 'Optional' is not defined
torch/functional.py:775: note: Did you forget to import it from "typing"? (Suggestion: "from typing import Optional")
torch/functional.py:780: error: Name 'Optional' is not defined
torch/functional.py:780: note: Did you forget to import it from "typing"? (Suggestion: "from typing import Optional")
torch/functional.py:780: error: Name 'number' is not defined
torch/functional.py:780: error: Name 'norm' already defined on line 775
torch/functional.py:785: error: Name 'Optional' is not defined
torch/functional.py:785: note: Did you forget to import it from "typing"? (Suggestion: "from typing import Optional")
torch/functional.py:785: error: Name 'number' is not defined
torch/functional.py:785: error: Name 'norm' already defined on line 775
torch/functional.py:790: error: Name 'Optional' is not defined
torch/functional.py:790: note: Did you forget to import it from "typing"? (Suggestion: "from typing import Optional")
torch/functional.py:790: error: Name 'norm' already defined on line 775
torch/functional.py:795: error: Name 'norm' already defined on line 775
torch/functional.py:960: error: Name 'Any' is not defined
torch/functional.py:960: note: Did you forget to import it from "typing"? (Suggestion: "from typing import Any")
torch/functional.py:960: error: Name 'Tuple' is not defined
torch/functional.py:960: note: Did you forget to import it from "typing"? (Suggestion: "from typing import Tuple")
torch/functional.py:1036: error: Argument 1 to "len" has incompatible type "int"; expected "Sized"
torch/functional.py:1041: error: Name 'Optional' is not defined
torch/functional.py:1041: note: Did you forget to import it from "typing"? (Suggestion: "from typing import Optional")
torch/functional.py:1041: error: Name 'Tuple' is not defined
torch/functional.py:1041: note: Did you forget to import it from "typing"? (Suggestion: "from typing import Tuple")
torch/functional.py:1056: error: Name 'Optional' is not defined
torch/functional.py:1056: note: Did you forget to import it from "typing"? (Suggestion: "from typing import Optional")
torch/functional.py:1056: error: Name 'Tuple' is not defined
torch/functional.py:1056: note: Did you forget to import it from "typing"? (Suggestion: "from typing import Tuple")
torch/distributions/von_mises.py:87: error: Incompatible types in assignment (expression has type "_Real", base class "Distribution" defined the type as "None")
torch/distributions/negative_binomial.py:25: error: Incompatible types in assignment (expression has type "_IntegerGreaterThan", base class "Distribution" defined the type as "None")
torch/distributions/multivariate_normal.py:116: error: Incompatible types in assignment (expression has type "_Real", base class "Distribution" defined the type as "None")
torch/distributions/laplace.py:23: error: Incompatible types in assignment (expression has type "_Real", base class "Distribution" defined the type as "None")
torch/distributions/independent.py:34: error: Need type annotation for 'arg_constraints' (hint: "arg_constraints: Dict[<type>, <type>] = ...")
torch/distributions/cauchy.py:28: error: Incompatible types in assignment (expression has type "_Real", base class "Distribution" defined the type as "None")
torch/distributions/poisson.py:28: error: Incompatible types in assignment (expression has type "_IntegerGreaterThan", base class "Distribution" defined the type as "None")
torch/distributions/one_hot_categorical.py:32: error: Incompatible types in assignment (expression has type "_Simplex", base class "Distribution" defined the type as "None")
torch/distributions/normal.py:27: error: Incompatible types in assignment (expression has type "_Real", base class "Distribution" defined the type as "None")
torch/distributions/lowrank_multivariate_normal.py:79: error: Incompatible types in assignment (expression has type "_Real", base class "Distribution" defined the type as "None")
torch/distributions/gamma.py:30: error: Incompatible types in assignment (expression has type "_GreaterThan", base class "Distribution" defined the type as "None")
torch/distributions/exponential.py:23: error: Incompatible types in assignment (expression has type "_GreaterThan", base class "Distribution" defined the type as "None")
torch/distributions/fishersnedecor.py:25: error: Incompatible types in assignment (expression has type "_GreaterThan", base class "Distribution" defined the type as "None")
torch/distributions/dirichlet.py:44: error: Incompatible types in assignment (expression has type "_Simplex", base class "Distribution" defined the type as "None")
torch/nn/quantized/dynamic/modules/rnn.py:230: error: Incompatible types in assignment (expression has type "int", variable has type "Tensor")
torch/nn/quantized/dynamic/modules/rnn.py:232: error: Incompatible types in assignment (expression has type "int", variable has type "Tensor")
torch/nn/quantized/dynamic/modules/rnn.py:236: error: Incompatible return value type (got "Tuple[Any, Tensor, Any]", expected "Tuple[int, int, int]")
torch/nn/quantized/dynamic/modules/rnn.py:351: error: Incompatible types in assignment (expression has type "Type[LSTM]", base class "RNNBase" defined the type as "Type[RNNBase]")
torch/nn/quantized/dynamic/modules/rnn.py:381: error: Module has no attribute "quantized_lstm"
torch/nn/quantized/dynamic/modules/rnn.py:385: error: Module has no attribute "quantized_lstm"
torch/nn/quantized/dynamic/modules/rnn.py:414: error: Argument 1 to "forward_impl" of "LSTM" has incompatible type "PackedSequence"; expected "Tensor"
torch/nn/quantized/dynamic/modules/rnn.py:416: error: Incompatible types in assignment (expression has type "PackedSequence", variable has type "Tensor")
torch/nn/quantized/dynamic/modules/rnn.py:418: error: Incompatible return value type (got "Tuple[Tensor, Tuple[Tensor, Tensor]]", expected "Tuple[PackedSequence, Tuple[Tensor, Tensor]]")
torch/nn/quantized/dynamic/modules/rnn.py:420: error: Argument 1 of "permute_hidden" is incompatible with supertype "RNNBase"; supertype defines the argument type as "Tensor"
torch/nn/quantized/dynamic/modules/rnn.py:420: error: Return type "Tuple[Tensor, Tensor]" of "permute_hidden" incompatible with return type "Tensor" in supertype "RNNBase"
torch/nn/quantized/dynamic/modules/rnn.py:426: error: Argument 2 of "check_forward_args" is incompatible with supertype "RNNBase"; supertype defines the argument type as "Tensor"
torch/nn/intrinsic/qat/modules/conv_fused.py:232: error: Incompatible types in assignment (expression has type "Type[ConvBnReLU2d]", base class "ConvBn2d" defined the type as "Type[ConvBn2d]")
torch/distributions/beta.py:27: error: Incompatible types in assignment (expression has type "_Interval", base class "Distribution" defined the type as "None")
torch/distributions/geometric.py:31: error: Incompatible types in assignment (expression has type "_IntegerGreaterThan", base class "Distribution" defined the type as "None")
torch/distributions/continuous_bernoulli.py:38: error: Incompatible types in assignment (expression has type "_Interval", base class "Distribution" defined the type as "None")
torch/distributions/bernoulli.py:30: error: Incompatible types in assignment (expression has type "_Boolean", base class "Distribution" defined the type as "None")
torch/quantization/fake_quantize.py:126: error: Module has no attribute "per_tensor_symmetric"
torch/quantization/fake_quantize.py:132: error: Module has no attribute "per_channel_symmetric"
torch/distributions/transformed_distribution.py:41: error: Need type annotation for 'arg_constraints' (hint: "arg_constraints: Dict[<type>, <type>] = ...")
torch/jit/__init__.py:1: error: Cannot find implementation or library stub for module named 'torch._C'
torch/jit/__init__.py:15: error: Module 'torch.utils' has no attribute 'set_module'
torch/jit/__init__.py:70: error: Name 'Attribute' already defined on line 68
torch/jit/__init__.py:213: error: On Python 3 '{}'.format(b'abc') produces "b'abc'"; use !r if this is a desired behavior
torch/jit/__init__.py:215: error: On Python 3 '{}'.format(b'abc') produces "b'abc'"; use !r if this is a desired behavior
torch/jit/__init__.py:1524: error: Unsupported dynamic base class "with_metaclass"
torch/jit/__init__.py:1869: error: Name 'ScriptModule' already defined on line 1524
torch/jit/__init__.py:1998: error: Need type annotation for '_jit_caching_layer'
torch/jit/__init__.py:1999: error: Need type annotation for '_jit_function_overload_caching'
torch/distributions/relaxed_categorical.py:34: error: Incompatible types in assignment (expression has type "_Real", base class "Distribution" defined the type as "None")
torch/distributions/relaxed_categorical.py:108: error: Incompatible types in assignment (expression has type "_Simplex", base class "Distribution" defined the type as "None")
torch/distributions/relaxed_bernoulli.py:31: error: Incompatible types in assignment (expression has type "_Real", base class "Distribution" defined the type as "None")
torch/distributions/relaxed_bernoulli.py:114: error: Incompatible types in assignment (expression has type "_Interval", base class "Distribution" defined the type as "None")
torch/distributions/logistic_normal.py:31: error: Incompatible types in assignment (expression has type "_Simplex", base class "Distribution" defined the type as "None")
torch/distributions/log_normal.py:26: error: Incompatible types in assignment (expression has type "_GreaterThan", base class "Distribution" defined the type as "None")
torch/distributions/half_normal.py:27: error: Incompatible types in assignment (expression has type "_GreaterThan", base class "Distribution" defined the type as "None")
torch/distributions/half_cauchy.py:28: error: Incompatible types in assignment (expression has type "_GreaterThan", base class "Distribution" defined the type as "None")
torch/distributions/gumbel.py:28: error: Incompatible types in assignment (expression has type "_Real", base class "Distribution" defined the type as "None")
torch/nn/quantized/modules/conv.py:18: error: Module 'torch.nn.utils' has no attribute 'fuse_conv_bn_weights'
torch/nn/quantized/modules/conv.py:209: error: Name 'Optional' is not defined
torch/nn/quantized/modules/conv.py:209: note: Did you forget to import it from "typing"? (Suggestion: "from typing import Optional")
torch/nn/quantized/modules/conv.py:214: error: Module has no attribute "ops"
torch/nn/quantized/modules/conv.py:321: error: Name 'Optional' is not defined
torch/nn/quantized/modules/conv.py:321: note: Did you forget to import it from "typing"? (Suggestion: "from typing import Optional")
torch/nn/quantized/modules/conv.py:323: error: Module has no attribute "ops"
torch/nn/quantized/modules/conv.py:447: error: Name 'Optional' is not defined
torch/nn/quantized/modules/conv.py:447: note: Did you forget to import it from "typing"? (Suggestion: "from typing import Optional")
torch/nn/quantized/modules/conv.py:449: error: Module has no attribute "ops"
torch/nn/quantized/modules/conv.py:513: error: Name 'nn.modules.conv._ConvTransposeNd' is not defined
torch/nn/quantized/modules/conv.py:525: error: Name 'List' is not defined
torch/nn/quantized/modules/conv.py:525: note: Did you forget to import it from "typing"? (Suggestion: "from typing import List")
torch/nn/quantized/modules/conv.py:527: error: Name 'List' is not defined
torch/nn/quantized/modules/conv.py:527: note: Did you forget to import it from "typing"? (Suggestion: "from typing import List")
torch/nn/intrinsic/quantized/modules/conv_relu.py:8: error: Module 'torch.nn.utils' has no attribute 'fuse_conv_bn_weights'
torch/nn/intrinsic/quantized/modules/conv_relu.py:21: error: Incompatible types in assignment (expression has type "Type[ConvReLU2d]", base class "Conv2d" defined the type as "Type[Conv2d]")
torch/nn/intrinsic/quantized/modules/conv_relu.py:62: error: Incompatible types in assignment (expression has type "Type[ConvReLU3d]", base class "Conv3d" defined the type as "Type[Conv3d]")
torch/distributions/weibull.py:25: error: Incompatible types in assignment (expression has type "_GreaterThan", base class "Distribution" defined the type as "None")
torch/distributions/kl.py:35: error: Need type annotation for '_KL_MEMOIZE' (hint: "_KL_MEMOIZE: Dict[<type>, <type>] = ...")
torch/distributions/studentT.py:27: error: Incompatible types in assignment (expression has type "_Real", base class "Distribution" defined the type as "None")
torch/distributions/mixture_same_family.py:48: error: Need type annotation for 'arg_constraints' (hint: "arg_constraints: Dict[<type>, <type>] = ...")
torch/distributions/__init__.py:158: error: Name 'transforms' is not defined
torch/onnx/utils.py:21: error: Cannot find implementation or library stub for module named 'torch._C'
torch/distributed/rendezvous.py:4: error: Cannot find implementation or library stub for module named 'urlparse'
torch/distributed/rendezvous.py:4: error: Name 'urlparse' already defined (possibly by an import)
torch/distributed/rendezvous.py:4: error: Name 'urlunparse' already defined (possibly by an import)
torch/distributed/rendezvous.py:9: error: Module 'torch.distributed' has no attribute 'FileStore'
torch/distributed/rendezvous.py:9: error: Module 'torch.distributed' has no attribute 'TCPStore'
torch/distributed/rendezvous.py:65: error: On Python 3 '{}'.format(b'abc') produces "b'abc'"; use !r if this is a desired behavior
torch/distributed/distributed_c10d.py:11: error: Module 'torch.distributed' has no attribute 'AllreduceOptions'; maybe "ReduceOptions" or "AllreduceCoalescedOptions"?
torch/distributed/distributed_c10d.py:11: error: Module 'torch.distributed' has no attribute 'AllreduceCoalescedOptions'; maybe "AllreduceOptions"?
torch/distributed/distributed_c10d.py:11: error: Module 'torch.distributed' has no attribute 'AllToAllOptions'
torch/distributed/distributed_c10d.py:11: error: Module 'torch.distributed' has no attribute 'BroadcastOptions'
torch/distributed/distributed_c10d.py:11: error: Module 'torch.distributed' has no attribute 'GatherOptions'; maybe "ScatterOptions"?
torch/distributed/distributed_c10d.py:11: error: Module 'torch.distributed' has no attribute 'ReduceOptions'; maybe "AllreduceOptions", "ReduceScatterOptions", or "ReduceOp"?
torch/distributed/distributed_c10d.py:11: error: Module 'torch.distributed' has no attribute 'ReduceScatterOptions'; maybe "ScatterOptions" or "ReduceOptions"?
torch/distributed/distributed_c10d.py:11: error: Module 'torch.distributed' has no attribute 'ScatterOptions'; maybe "ReduceScatterOptions" or "GatherOptions"?
torch/distributed/distributed_c10d.py:21: error: Module 'torch.distributed' has no attribute 'ReduceOp'; maybe "ReduceOptions"?
torch/distributed/distributed_c10d.py:22: error: Module 'torch.distributed' has no attribute 'PrefixStore'
torch/distributed/distributed_c10d.py:31: error: Module 'torch.distributed' has no attribute 'ProcessGroupMPI'; maybe "ProcessGroupNCCL" or "ProcessGroupGloo"?
torch/distributed/distributed_c10d.py:36: error: Module 'torch.distributed' has no attribute 'ProcessGroupNCCL'; maybe "ProcessGroupMPI"?
torch/distributed/distributed_c10d.py:41: error: Module 'torch.distributed' has no attribute 'ProcessGroupGloo'; maybe "ProcessGroupMPI"?
torch/distributed/distributed_c10d.py:79: error: On Python 3 '{}'.format(b'abc') produces "b'abc'"; use !r if this is a desired behavior
torch/distributed/distributed_c10d.py:129: error: Cannot assign to a type
torch/distributed/distributed_c10d.py:129: error: Incompatible types in assignment (expression has type "reduce_op", variable has type "Type[reduce_op]")
torch/distributed/distributed_c10d.py:145: error: Need type annotation for '_pg_map' (hint: "_pg_map: Dict[<type>, <type>] = ...")
torch/distributed/distributed_c10d.py:147: error: Need type annotation for '_pg_names' (hint: "_pg_names: Dict[<type>, <type>] = ...")
torch/distributed/distributed_c10d.py:149: error: Need type annotation for '_pg_group_ranks' (hint: "_pg_group_ranks: Dict[<type>, <type>] = ...")
torch/onnx/symbolic_helper.py:4: error: Cannot find implementation or library stub for module named 'torch._C'
torch/onnx/symbolic_helper.py:557: error: Need type annotation for '_quantized_ops' (hint: "_quantized_ops: Set[<type>] = ...")
torch/onnx/symbolic_opset9.py:7: error: Cannot find implementation or library stub for module named 'torch._C'
caffe2/python/_import_c_extension.py:27: error: Skipping analyzing 'caffe2.python.caffe2_pybind11_state_gpu': found module but no type hints or library stubs
caffe2/python/_import_c_extension.py:28: error: Name 'num_cuda_devices' is not defined
caffe2/python/_import_c_extension.py:33: error: Skipping analyzing 'caffe2.python.caffe2_pybind11_state_hip': found module but no type hints or library stubs
caffe2/python/_import_c_extension.py:47: error: Skipping analyzing 'caffe2.python.caffe2_pybind11_state': found module but no type hints or library stubs
caffe2/python/_import_c_extension.py:55: error: Name 'on_module_exit' is not defined
caffe2/python/_import_c_extension.py:66: error: Name 'TensorCPU' is not defined
caffe2/python/_import_c_extension.py:67: error: Name 'TensorCPU' is not defined
torch/storage.py:139: error: "Type[_StorageBase]" has no attribute "type"
torch/storage.py:140: error: "Type[_StorageBase]" has no attribute "cuda"
torch/_torch_docs.py:5: error: Cannot find implementation or library stub for module named 'torch._C'
torch/_storage_docs.py:3: error: Cannot find implementation or library stub for module named 'torch._C'
torch/_lobpcg.py:14: error: Name 'Tuple' is not defined
torch/_lobpcg.py:14: note: Did you forget to import it from "typing"? (Suggestion: "from typing import Tuple")
torch/_lobpcg.py:14: error: Name 'Tensor' is not defined
torch/_lobpcg.py:15: error: Name 'Optional' is not defined
torch/_lobpcg.py:15: note: Did you forget to import it from "typing"? (Suggestion: "from typing import Optional")
torch/_lobpcg.py:16: error: Name 'Optional' is not defined
torch/_lobpcg.py:16: note: Did you forget to import it from "typing"? (Suggestion: "from typing import Optional")
torch/_lobpcg.py:16: error: Name 'Tensor' is not defined
torch/_lobpcg.py:17: error: Name 'Optional' is not defined
torch/_lobpcg.py:17: note: Did you forget to import it from "typing"? (Suggestion: "from typing import Optional")
torch/_lobpcg.py:17: error: Name 'Tensor' is not defined
torch/_lobpcg.py:18: error: Name 'Optional' is not defined
torch/_lobpcg.py:18: note: Did you forget to import it from "typing"? (Suggestion: "from typing import Optional")
torch/_lobpcg.py:19: error: Name 'Optional' is not defined
torch/_lobpcg.py:19: note: Did you forget to import it from "typing"? (Suggestion: "from typing import Optional")
torch/_lobpcg.py:19: error: Name 'Tensor' is not defined
torch/_lobpcg.py:20: error: Name 'Optional' is not defined
torch/_lobpcg.py:20: note: Did you forget to import it from "typing"? (Suggestion: "from typing import Optional")
torch/_lobpcg.py:21: error: Name 'Optional' is not defined
torch/_lobpcg.py:21: note: Did you forget to import it from "typing"? (Suggestion: "from typing import Optional")
torch/_lobpcg.py:22: error: Name 'Optional' is not defined
torch/_lobpcg.py:22: note: Did you forget to import it from "typing"? (Suggestion: "from typing import Optional")
torch/_lobpcg.py:23: error: Name 'Optional' is not defined
torch/_lobpcg.py:23: note: Did you forget to import it from "typing"? (Suggestion: "from typing import Optional")
torch/_lobpcg.py:24: error: Name 'Optional' is not defined
torch/_lobpcg.py:24: note: Did you forget to import it from "typing"? (Suggestion: "from typing import Optional")
torch/_lobpcg.py:25: error: Name 'Optional' is not defined
torch/_lobpcg.py:25: note: Did you forget to import it from "typing"? (Suggestion: "from typing import Optional")
torch/_lobpcg.py:25: error: Name 'Dict' is not defined
torch/_lobpcg.py:25: note: Did you forget to import it from "typing"? (Suggestion: "from typing import Dict")
torch/_lobpcg.py:26: error: Name 'Optional' is not defined
torch/_lobpcg.py:26: note: Did you forget to import it from "typing"? (Suggestion: "from typing import Optional")
torch/_lobpcg.py:26: error: Name 'Dict' is not defined
torch/_lobpcg.py:26: note: Did you forget to import it from "typing"? (Suggestion: "from typing import Dict")
torch/_lobpcg.py:27: error: Name 'Optional' is not defined
torch/_lobpcg.py:27: note: Did you forget to import it from "typing"? (Suggestion: "from typing import Optional")
torch/_lobpcg.py:27: error: Name 'Dict' is not defined
torch/_lobpcg.py:27: note: Did you forget to import it from "typing"? (Suggestion: "from typing import Dict")
torch/_lobpcg.py:230: error: Cannot assign to a method
torch/_lobpcg.py:252: error: Cannot assign to a method
torch/_lobpcg.py:264: error: Cannot assign to a method
torch/_lobpcg.py:274: error: Name 'Optional' is not defined
torch/_lobpcg.py:274: note: Did you forget to import it from "typing"? (Suggestion: "from typing import Optional")
torch/_lobpcg.py:274: error: Name 'Tensor' is not defined
torch/_lobpcg.py:275: error: Name 'Optional' is not defined
torch/_lobpcg.py:275: note: Did you forget to import it from "typing"? (Suggestion: "from typing import Optional")
torch/_lobpcg.py:275: error: Name 'Tensor' is not defined
torch/_lobpcg.py:276: error: Name 'Tensor' is not defined
torch/_lobpcg.py:277: error: Name 'Optional' is not defined
torch/_lobpcg.py:277: note: Did you forget to import it from "typing"? (Suggestion: "from typing import Optional")
torch/_lobpcg.py:277: error: Name 'Tensor' is not defined
torch/_lobpcg.py:278: error: Name 'Dict' is not defined
torch/_lobpcg.py:278: note: Did you forget to import it from "typing"? (Suggestion: "from typing import Dict")
torch/_lobpcg.py:279: error: Name 'Dict' is not defined
torch/_lobpcg.py:279: note: Did you forget to import it from "typing"? (Suggestion: "from typing import Dict")
torch/_lobpcg.py:280: error: Name 'Dict' is not defined
torch/_lobpcg.py:280: note: Did you forget to import it from "typing"? (Suggestion: "from typing import Dict")
torch/_lobpcg.py:282: error: Name 'Optional' is not defined
torch/_lobpcg.py:282: note: Did you forget to import it from "typing"? (Suggestion: "from typing import Optional")
torch/_lobpcg.py:303: error: Name 'Dict' is not defined
torch/_lobpcg.py:303: note: Did you forget to import it from "typing"? (Suggestion: "from typing import Dict")
torch/_lobpcg.py:304: error: Name 'Dict' is not defined
torch/_lobpcg.py:304: note: Did you forget to import it from "typing"? (Suggestion: "from typing import Dict")
torch/_lobpcg.py:305: error: Name 'Dict' is not defined
torch/_lobpcg.py:305: note: Did you forget to import it from "typing"? (Suggestion: "from typing import Dict")
torch/_lobpcg.py:306: error: Name 'Dict' is not defined
torch/_lobpcg.py:306: note: Did you forget to import it from "typing"? (Suggestion: "from typing import Dict")
torch/_lobpcg.py:569: error: Name 'Tensor' is not defined
torch/utils/throughput_benchmark.py:3: error: Cannot find implementation or library stub for module named 'torch._C'
torch/utils/dlpack.py:4: error: Cannot find implementation or library stub for module named 'torch._C'
torch/utils/cpp_extension.py:7: error: Skipping analyzing 'setuptools': found module but no type hints or library stubs
torch/utils/cpp_extension.py:21: error: Skipping analyzing 'setuptools.command.build_ext': found module but no type hints or library stubs
torch/utils/bundled_inputs.py:129: error: "Storage" has no attribute "size"
torch/utils/bundled_inputs.py:130: error: Incompatible return value type (got "Tuple[Tensor, str]", expected "Tuple[T, str]")
torch/utils/bundled_inputs.py:134: error: Incompatible return value type (got "Tuple[Tensor, str]", expected "Tuple[T, str]")
torch/utils/bundled_inputs.py:138: error: Incompatible return value type (got "Tuple[Tensor, str]", expected "Tuple[T, str]")
torch/utils/bundled_inputs.py:142: error: "Storage" has no attribute "size"
torch/utils/tensorboard/_pytorch_graph.py:3: error: Cannot find implementation or library stub for module named 'tensorboard.compat.proto.config_pb2'
torch/utils/tensorboard/_pytorch_graph.py:4: error: Cannot find implementation or library stub for module named 'tensorboard.compat.proto.graph_pb2'
torch/utils/tensorboard/_pytorch_graph.py:5: error: Cannot find implementation or library stub for module named 'tensorboard.compat.proto.step_stats_pb2'
torch/utils/tensorboard/_pytorch_graph.py:6: error: Cannot find implementation or library stub for module named 'tensorboard.compat.proto.versions_pb2'
torch/utils/data/dataset.pyi:9: error: Cannot use a covariant type variable as a parameter
torch/quantization/_quantize_script.py:17: error: Name 'List' is not defined
torch/quantization/_quantize_script.py:17: note: Did you forget to import it from "typing"? (Suggestion: "from typing import List")
torch/quantization/_quantize_script.py:25: error: Name 'Optional' is not defined
torch/quantization/_quantize_script.py:25: note: Did you forget to import it from "typing"? (Suggestion: "from typing import Optional")
torch/quantization/_quantize_script.py:28: error: Module has no attribute "ops"
torch/quantization/_quantize_script.py:61: error: Module has no attribute "supported_engines"
torch/onnx/symbolic_opset8.py:8: error: Module 'torch.onnx.symbolic_opset9' has no attribute '_cast_Float'
torch/nn/cpp.py:81: error: Signature of "training" incompatible with supertype "Module"
torch/nn/utils/prune.py:13: error: Cannot assign to a type
torch/nn/utils/prune.py:13: error: Incompatible types in assignment (expression has type "ABCMeta", variable has type "Type[ABC]")
torch/nn/utils/prune.py:13: note: "ABCMeta.__call__" has type "Callable[[VarArg(Any), KwArg(Any)], Any]"
torch/jit/quantized.py:179: error: Module has no attribute "quantized_rnn_tanh_cell"
torch/jit/quantized.py:186: error: Module has no attribute "quantized_rnn_relu_cell"
torch/jit/quantized.py:212: error: Module has no attribute "quantized_lstm_cell"
torch/jit/quantized.py:231: error: Module has no attribute "quantized_gru_cell"
torch/jit/quantized.py:369: error: Incompatible types in assignment (expression has type "int", variable has type "Tensor")
torch/jit/quantized.py:371: error: Incompatible types in assignment (expression has type "int", variable has type "Tensor")
torch/jit/quantized.py:375: error: Incompatible return value type (got "Tuple[Any, Tensor, Any]", expected "Tuple[int, int, int]")
torch/jit/quantized.py:468: error: Module has no attribute "quantized_lstm"
torch/jit/quantized.py:544: error: Module has no attribute "quantized_gru"
torch/jit/quantized.py:548: error: Module has no attribute "quantized_gru"
torch/jit/_logging.py:3: error: Module has no attribute "ops"
torch/jit/_logging.py:10: error: Module has no attribute "ops"
torch/cuda/random.py:2: error: Module 'torch.cuda' has no attribute '_lazy_init'
torch/cuda/random.py:2: error: Module 'torch.cuda' has no attribute '_lazy_call'
torch/cuda/profiler.py:3: error: Module 'torch.cuda' has no attribute 'cudart'
torch/cuda/memory.py:6: error: Module 'torch.cuda' has no attribute 'is_initialized'
torch/cuda/memory.py:6: error: Module 'torch.cuda' has no attribute '_get_device_index'; maybe "get_device_name"?
torch/cuda/_utils.py:33: error: Not all arguments converted during string formatting
torch/backends/quantized/__init__.py:24: error: Incompatible return value type (got "Optional[str]", expected "str")
torch/backends/cudnn/rnn.py:4: error: Cannot find implementation or library stub for module named 'torch._C'
torch/backends/cuda/__init__.py:98: error: Incompatible types in assignment (expression has type "CUDAModule", target has type Module)
torch/autograd/variable.py:10: error: Unsupported dynamic base class "with_metaclass"
torch/autograd/variable.py:14: error: Cannot find implementation or library stub for module named 'torch._C'
torch/_tensor_docs.py:3: error: Cannot find implementation or library stub for module named 'torch._C'
torch/utils/data/distributed.pyi:7: error: Return type "Iterator[int]" of "__iter__" incompatible with return type "Iterator[T_co]" in supertype "Sampler"
torch/utils/data/__init__.pyi:4: error: Module 'torch.utils.data.dataset' has no attribute 'ChainDataset'
torch/utils/data/__init__.pyi:7: error: Module 'torch.utils.data.dataloader' has no attribute 'get_worker_info'
torch/testing/_internal/hypothesis_utils.py:317: error: "Type[settings]" has no attribute "_current_profile"
torch/testing/_internal/hypothesis_utils.py:320: error: Module has no attribute "unlimited"
torch/distributed/rpc/backend_registry.py:23: error: Unexpected arguments to Enum()
torch/distributed/rpc/backend_registry.py:24: error: Cannot assign to a method
torch/distributed/rpc/api.py:13: error: Module 'torch.distributed.rpc' has no attribute '_cleanup_python_rpc_handler'
torch/distributed/rpc/api.py:13: error: Module 'torch.distributed.rpc' has no attribute '_delete_all_user_rrefs'
torch/distributed/rpc/api.py:13: error: Module 'torch.distributed.rpc' has no attribute '_destroy_rref_context'
torch/distributed/rpc/api.py:13: error: Module 'torch.distributed.rpc' has no attribute '_get_current_rpc_agent'
torch/distributed/rpc/api.py:13: error: Module 'torch.distributed.rpc' has no attribute '_invoke_remote_builtin'
torch/distributed/rpc/api.py:13: error: Module 'torch.distributed.rpc' has no attribute '_invoke_remote_python_udf'
torch/distributed/rpc/api.py:13: error: Module 'torch.distributed.rpc' has no attribute '_invoke_remote_torchscript'
torch/distributed/rpc/api.py:13: error: Module 'torch.distributed.rpc' has no attribute '_invoke_rpc_builtin'
torch/distributed/rpc/api.py:13: error: Module 'torch.distributed.rpc' has no attribute '_invoke_rpc_python_udf'
torch/distributed/rpc/api.py:13: error: Module 'torch.distributed.rpc' has no attribute '_invoke_rpc_torchscript'
torch/distributed/rpc/api.py:13: error: Module 'torch.distributed.rpc' has no attribute '_is_current_rpc_agent_set'
torch/distributed/rpc/api.py:13: error: Module 'torch.distributed.rpc' has no attribute '_reset_current_rpc_agent'
torch/distributed/rpc/api.py:13: error: Module 'torch.distributed.rpc' has no attribute '_set_and_start_rpc_agent'
torch/distributed/rpc/api.py:13: error: Module 'torch.distributed.rpc' has no attribute '_set_rpc_timeout'
torch/distributed/rpc/api.py:13: error: Module 'torch.distributed.rpc' has no attribute 'RpcBackendOptions'
torch/distributed/rpc/api.py:13: error: Module 'torch.distributed.rpc' has no attribute 'WorkerInfo'
torch/distributed/rpc/api.py:104: error: Need type annotation for '_wait_all_workers_sequence_id_to_states'
torch/distributed/rpc/constants.py:3: error: Module 'torch.distributed.rpc' has no attribute '_DEFAULT_RPC_TIMEOUT'
torch/distributed/rpc/constants.py:3: error: Module 'torch.distributed.rpc' has no attribute '_DEFAULT_INIT_METHOD'
torch/distributed/rpc/constants.py:3: error: Module 'torch.distributed.rpc' has no attribute '_DEFAULT_NUM_SEND_RECV_THREADS'
caffe2/python/context.py:86: error: 'classmethod' used with a non-method
torch/tensor.py:3: error: Cannot find implementation or library stub for module named 'torch._C'
torch/tensor.py:421: error: Signatures of "__ipow__" and "__pow__" are incompatible
torch/utils/data/_utils/worker.py:47: error: Name 'ManagerWatchdog' already defined on line 22
torch/utils/data/_utils/signal_handling.py:39: error: Cannot find implementation or library stub for module named 'torch._C'
torch/testing/_internal/dist_utils.py:9: error: Module 'torch.distributed.rpc' has no attribute '_rref_context_get_debug_info'
torch/testing/_internal/dist_utils.py:14: error: Name 'sys' is not defined
torch/testing/_internal/dist_utils.py:91: error: "TestConfig" has no attribute "rpc_backend_name"
torch/testing/_internal/dist_utils.py:92: error: "TestConfig" has no attribute "build_rpc_backend_options"
caffe2/python/mint/app.py:7: error: Cannot find implementation or library stub for module named 'nvd3'
torch/testing/_internal/distributed/rpc/dist_optimizer_test.py:36: error: Name 'optim.Optimizer' is not defined
torch/testing/_internal/distributed/rpc/dist_optimizer_test.py:44: error: Name 'optim.Optimizer' is not defined
torch/testing/_internal/distributed/rpc/jit/dist_autograd_test.py:43: error: Module has no attribute "get_gradients"
caffe2/python/utils.py:10: error: Skipping analyzing 'future.utils': found module but no type hints or library stubs
caffe2/python/utils.py:12: error: Module 'google.protobuf' has no attribute 'text_format'
caffe2/python/workspace.py:15: error: Skipping analyzing 'past.builtins': found module but no type hints or library stubs
caffe2/python/workspace.py:27: error: Module has no attribute "blobs"
caffe2/python/workspace.py:28: error: Module has no attribute "reset_blob"
caffe2/python/workspace.py:29: error: Module has no attribute "create_blob"
caffe2/python/workspace.py:30: error: Module has no attribute "current_workspace"
caffe2/python/workspace.py:31: error: Module has no attribute "deserialize_blob"
caffe2/python/workspace.py:32: error: Module has no attribute "global_init"
caffe2/python/workspace.py:33: error: Module has no attribute "has_blob"
caffe2/python/workspace.py:34: error: Module has no attribute "registered_operators"
caffe2/python/workspace.py:35: error: Module has no attribute "serialize_blob"
caffe2/python/workspace.py:36: error: Module has no attribute "switch_workspace"
caffe2/python/workspace.py:37: error: Module has no attribute "root_folder"
caffe2/python/workspace.py:38: error: Module has no attribute "workspaces"
caffe2/python/workspace.py:39: error: Module has no attribute "benchmark_net"
caffe2/python/workspace.py:40: error: Module has no attribute "benchmark_net_once"
caffe2/python/workspace.py:41: error: Module has no attribute "get_stats"
caffe2/python/workspace.py:43: error: Need type annotation for 'operator_tracebacks'
caffe2/python/workspace.py:45: error: Module has no attribute "is_asan"
caffe2/python/workspace.py:50: error: Module has no attribute "CUDA"
caffe2/python/workspace.py:51: error: Module has no attribute "num_cuda_devices"
caffe2/python/workspace.py:54: error: Module has no attribute "num_cuda_devices"
caffe2/python/workspace.py:55: error: Module has no attribute "get_cuda_version"
caffe2/python/workspace.py:56: error: Module has no attribute "get_cudnn_version"
caffe2/python/workspace.py:61: error: Module has no attribute "get_device_properties"
caffe2/python/workspace.py:62: error: Module has no attribute "get_gpu_memory_info"
caffe2/python/workspace.py:69: error: Module has no attribute "HIP"
caffe2/python/workspace.py:70: error: Module has no attribute "num_hip_devices"
caffe2/python/workspace.py:74: error: Module has no attribute "get_device_properties"
caffe2/python/workspace.py:75: error: Module has no attribute "get_gpu_memory_info"
caffe2/python/workspace.py:80: error: Module has no attribute "CUDA"
caffe2/python/workspace.py:86: error: Module has no attribute "is_numa_enabled"
caffe2/python/workspace.py:87: error: Module has no attribute "get_num_numa_nodes"
caffe2/python/workspace.py:88: error: Module has no attribute "get_blob_numa_node"
caffe2/python/workspace.py:89: error: Module has no attribute "get_blob_size_bytes"
caffe2/python/workspace.py:448: error: Module has no attribute "Workspace"
caffe2/python/workspace.py:721: error: Module has no attribute "Workspace"
caffe2/python/workspace.py:745: error: Module has no attribute "Blob"
caffe2/python/workspace.py:760: error: Module has no attribute "TensorCPU"
caffe2/python/workspace.py:768: error: Module has no attribute "Blob"
caffe2/python/core.py:9: error: Skipping analyzing 'past.builtins': found module but no type hints or library stubs
caffe2/python/core.py:10: error: Skipping analyzing 'future.utils': found module but no type hints or library stubs
caffe2/python/core.py:1064: error: Need type annotation for 'gradient_registry_' (hint: "gradient_registry_: Dict[<type>, <type>] = ...")
caffe2/python/core.py:1403: error: Need type annotation for '_net_names_used' (hint: "_net_names_used: Set[<type>] = ...")
caffe2/python/core.py:1404: error: Need type annotation for 'operator_registry_' (hint: "operator_registry_: Dict[<type>, <type>] = ...")
caffe2/python/core.py:2602: error: Need type annotation for '_step_names_used' (hint: "_step_names_used: Set[<type>] = ...")
caffe2/python/core.py:2999: error: Module has no attribute "set_per_op_engine_pref"
caffe2/python/core.py:3000: error: Module has no attribute "set_global_engine_pref"
caffe2/python/core.py:3001: error: Module has no attribute "set_engine_pref"
caffe2/python/core.py:3002: error: Module has no attribute "set_op_engine_pref"
caffe2/python/schema.py:27: error: Skipping analyzing 'past.builtins': found module but no type hints or library stubs
caffe2/python/schema.py:28: error: Skipping analyzing 'future.utils': found module but no type hints or library stubs
caffe2/python/schema.py:71: error: "Callable[[Type[_NT], Any, Any, Any, Any, Any, Any], _NT]" has no attribute "__defaults__"
caffe2/python/schema.py:94: error: "Callable[[Type[_NT], Any, Any, Any], _NT]" has no attribute "__defaults__"
caffe2/python/schema.py:1241: error: "Type[DataType]" has no attribute "STRING"
caffe2/python/schema.py:1242: error: "Type[DataType]" has no attribute "FLOAT16"
caffe2/python/schema.py:1243: error: "Type[DataType]" has no attribute "FLOAT"
caffe2/python/schema.py:1244: error: "Type[DataType]" has no attribute "DOUBLE"
caffe2/python/schema.py:1245: error: "Type[DataType]" has no attribute "BOOL"
caffe2/python/schema.py:1246: error: "Type[DataType]" has no attribute "INT8"
caffe2/python/schema.py:1247: error: "Type[DataType]" has no attribute "INT16"
caffe2/python/schema.py:1248: error: "Type[DataType]" has no attribute "INT32"
caffe2/python/schema.py:1249: error: "Type[DataType]" has no attribute "INT64"
caffe2/python/schema.py:1250: error: "Type[DataType]" has no attribute "UINT8"
caffe2/python/schema.py:1251: error: "Type[DataType]" has no attribute "UINT16"
caffe2/python/task.py:12: error: Skipping analyzing 'future.utils': found module but no type hints or library stubs
caffe2/python/task.py:482: error: Need type annotation for '_global_names_used' (hint: "_global_names_used: Set[<type>] = ...")
torch/utils/tensorboard/_caffe2_graph.py:12: error: Cannot find implementation or library stub for module named 'tensorboard.compat.proto.graph_pb2'
torch/utils/tensorboard/_caffe2_graph.py:13: error: Cannot find implementation or library stub for module named 'tensorboard.compat.proto.node_def_pb2'
torch/utils/tensorboard/_caffe2_graph.py:14: error: Cannot find implementation or library stub for module named 'tensorboard.compat.proto.tensor_shape_pb2'
torch/testing/_internal/common_utils.py:38: error: Cannot find implementation or library stub for module named '__main__'
torch/testing/_internal/common_utils.py:199: error: Cannot find implementation or library stub for module named 'xmlrunner'
torch/testing/_internal/common_cuda.py:12: error: Argument "device" to "tensor" has incompatible type "Union[bool, device]"; expected "Union[device, str, None]"
torch/testing/_internal/common_cuda.py:16: error: Skipping analyzing 'numba.cuda': found module but no type hints or library stubs
torch/testing/_internal/common_cuda.py:16: error: Skipping analyzing 'numba': found module but no type hints or library stubs
torch/utils/tensorboard/summary.py:13: error: Cannot find implementation or library stub for module named 'tensorboard.compat.proto.summary_pb2'
torch/utils/tensorboard/summary.py:16: error: Cannot find implementation or library stub for module named 'tensorboard.compat.proto.tensor_pb2'
torch/utils/tensorboard/summary.py:17: error: Cannot find implementation or library stub for module named 'tensorboard.compat.proto.tensor_shape_pb2'
torch/utils/tensorboard/summary.py:18: error: Cannot find implementation or library stub for module named 'tensorboard.plugins.text.plugin_data_pb2'
torch/utils/tensorboard/summary.py:19: error: Cannot find implementation or library stub for module named 'tensorboard.plugins.pr_curve.plugin_data_pb2'
torch/utils/tensorboard/summary.py:20: error: Cannot find implementation or library stub for module named 'tensorboard.plugins.custom_scalar'
torch/utils/tensorboard/summary.py:31: error: Skipping analyzing 'PIL': found module but no type hints or library stubs
torch/utils/tensorboard/summary.py:72: error: Cannot find implementation or library stub for module named 'tensorboard.plugins.hparams.api_pb2'
torch/utils/tensorboard/summary.py:75: error: Cannot find implementation or library stub for module named 'tensorboard.plugins.hparams.metadata'
torch/utils/tensorboard/summary.py:82: error: Cannot find implementation or library stub for module named 'tensorboard.plugins.hparams.plugin_data_pb2'
torch/utils/tensorboard/summary.py:373: error: Cannot find implementation or library stub for module named 'moviepy'
torch/utils/tensorboard/summary.py:567: error: Cannot find implementation or library stub for module named 'tensorboard.plugins.mesh'
torch/utils/tensorboard/summary.py:626: error: Cannot find implementation or library stub for module named 'tensorboard.plugins.mesh.plugin_data_pb2'
torch/utils/tensorboard/_embedding.py:5: error: Cannot find implementation or library stub for module named 'tensorboard.compat'
torch/utils/tensorboard/_embedding.py:6: error: Cannot find implementation or library stub for module named 'tensorboard.plugins.projector.projector_config_pb2'
torch/utils/tensorboard/_embedding.py:25: error: Skipping analyzing 'PIL': found module but no type hints or library stubs
torch/testing/_internal/common_nn.py:17: error: Module 'torch.nn.functional' has no attribute '_Reduction'
torch/testing/_internal/common_nn.py:1872: error: Unexpected keyword argument "divisor_override" for "AvgPool2d"
torch/nn/modules/pooling.pyi:114: note: "AvgPool2d" defined here
torch/testing/_internal/common_nn.py:1879: error: Unexpected keyword argument "divisor_override" for "AvgPool2d"
torch/nn/modules/pooling.pyi:114: note: "AvgPool2d" defined here
torch/testing/_internal/common_nn.py:1886: error: Unexpected keyword argument "divisor_override" for "AvgPool2d"
torch/nn/modules/pooling.pyi:114: note: "AvgPool2d" defined here
torch/testing/_internal/common_nn.py:2145: error: Unexpected keyword argument "divisor_override" for "AvgPool3d"
torch/nn/modules/pooling.pyi:129: note: "AvgPool3d" defined here
torch/testing/_internal/common_nn.py:2152: error: Unexpected keyword argument "divisor_override" for "AvgPool3d"
torch/nn/modules/pooling.pyi:129: note: "AvgPool3d" defined here
torch/testing/_internal/common_nn.py:2159: error: Unexpected keyword argument "divisor_override" for "AvgPool3d"
torch/nn/modules/pooling.pyi:129: note: "AvgPool3d" defined here
torch/testing/_internal/common_nn.py:2166: error: Unexpected keyword argument "divisor_override" for "AvgPool3d"
torch/nn/modules/pooling.pyi:129: note: "AvgPool3d" defined here
torch/testing/_internal/common_nn.py:2173: error: Unexpected keyword argument "divisor_override" for "AvgPool3d"
torch/nn/modules/pooling.pyi:129: note: "AvgPool3d" defined here
torch/testing/_internal/common_nn.py:2180: error: Unexpected keyword argument "divisor_override" for "AvgPool3d"
torch/nn/modules/pooling.pyi:129: note: "AvgPool3d" defined here
torch/testing/_internal/common_nn.py:2187: error: Unexpected keyword argument "divisor_override" for "AvgPool3d"
torch/nn/modules/pooling.pyi:129: note: "AvgPool3d" defined here
torch/testing/_internal/common_nn.py:3621: error: Too many arguments for "Tensor"
torch/testing/_internal/common_nn.py:3632: error: Too many arguments for "Tensor"
torch/testing/_internal/common_nn.py:3642: error: Too many arguments for "Tensor"
torch/testing/_internal/common_nn.py:3653: error: Too many arguments for "Tensor"
torch/testing/_internal/common_nn.py:3664: error: Too many arguments for "Tensor"
torch/testing/_internal/common_nn.py:3719: error: Too many arguments for "Tensor"
torch/testing/_internal/common_nn.py:3726: error: Too many arguments for "Tensor"
torch/testing/_internal/common_nn.py:3916: error: Cannot call function of unknown type
torch/testing/_internal/common_nn.py:3928: error: Cannot call function of unknown type
torch/testing/_internal/common_nn.py:3939: error: Cannot call function of unknown type
torch/testing/_internal/common_nn.py:3948: error: Cannot call function of unknown type
torch/testing/_internal/common_nn.py:3958: error: Cannot call function of unknown type
torch/testing/_internal/common_nn.py:4639: error: Definition of "_get_input" in base class "InputVariableMixin" is incompatible with definition in base class "TestBase"
torch/testing/_internal/common_nn.py:4791: error: Definition of "_get_input" in base class "InputVariableMixin" is incompatible with definition in base class "TestBase"
torch/testing/_internal/common_nn.py:4816: error: All conditional function variants must have identical signatures
torch/testing/_internal/common_distributed.py:108: error: Need type annotation for 'TIMEOUT_OVERRIDE' (hint: "TIMEOUT_OVERRIDE: Dict[<type>, <type>] = ...")
torch/testing/_internal/common_device_type.py:161: error: Signature of "precision" incompatible with supertype "TestCase"
torch/testing/_internal/common_device_type.py:278: error: Argument 1 to "append" of "list" has incompatible type "Type[CUDATestBase]"; expected "Type[CPUTestBase]"
torch/testing/_internal/distributed/rpc/dist_autograd_test.py:76: error: Name 'Tensor' is not defined
torch/testing/_internal/distributed/rpc/dist_autograd_test.py:100: error: Name 'RRef' is not defined
torch/testing/_internal/distributed/rpc/dist_autograd_test.py:100: error: Name 'Tensor' is not defined
torch/testing/_internal/distributed/rpc/jit/rpc_test.py:18: error: Name 'RRef' is not defined
torch/testing/_internal/distributed/rpc/jit/rpc_test.py:35: error: Name 'RRef' is not defined
torch/testing/_internal/distributed/rpc/jit/rpc_test.py:153: error: Name 'RRef' is not defined
torch/testing/_internal/distributed/rpc/jit/rpc_test.py:159: error: Name 'RRef' is not defined
torch/testing/_internal/distributed/rpc/jit/rpc_test.py:208: error: Name 'RRef' is not defined
torch/testing/_internal/distributed/rpc/jit/rpc_test.py:211: error: Name 'Any' is not defined
torch/testing/_internal/distributed/rpc/jit/rpc_test.py:211: note: Did you forget to import it from "typing"? (Suggestion: "from typing import Any")
torch/testing/_internal/distributed/rpc/jit/rpc_test.py:239: error: Name 'RRef' is not defined
torch/testing/_internal/distributed/rpc/jit/rpc_test.py:242: error: Name 'Any' is not defined
torch/testing/_internal/distributed/rpc/jit/rpc_test.py:242: note: Did you forget to import it from "typing"? (Suggestion: "from typing import Any")
torch/testing/_internal/distributed/rpc/jit/rpc_test.py:393: error: Name 'Any' is not defined
torch/testing/_internal/distributed/rpc/jit/rpc_test.py:393: note: Did you forget to import it from "typing"? (Suggestion: "from typing import Any")
torch/testing/_internal/distributed/rpc/jit/rpc_test.py:465: error: Need type annotation for 'kwargs' (hint: "kwargs: Dict[<type>, <type>] = ...")
torch/testing/_internal/distributed/rpc/jit/rpc_test.py:494: error: Need type annotation for 'kwargs' (hint: "kwargs: Dict[<type>, <type>] = ...")
torch/testing/_internal/distributed/rpc/jit/rpc_test.py:535: error: Need type annotation for 'kwargs' (hint: "kwargs: Dict[<type>, <type>] = ...")
torch/testing/_internal/distributed/rpc/jit/rpc_test.py:561: error: Need type annotation for 'kwargs' (hint: "kwargs: Dict[<type>, <type>] = ...")
torch/testing/_internal/distributed/rpc/jit/rpc_test.py:588: error: Need type annotation for 'kwargs' (hint: "kwargs: Dict[<type>, <type>] = ...")
torch/testing/_internal/distributed/rpc/jit/rpc_test.py:602: error: Name 'RRef' is not defined
torch/testing/_internal/distributed/rpc/jit/rpc_test.py:608: error: Name 'RRef' is not defined
torch/testing/_internal/distributed/rpc/jit/rpc_test.py:626: error: Name 'RRef' is not defined
torch/testing/_internal/distributed/rpc/jit/rpc_test.py:633: error: Name 'RRef' is not defined
torch/testing/_internal/distributed/rpc/jit/rpc_test.py:639: error: Name 'RRef' is not defined
torch/testing/_internal/distributed/rpc/jit/rpc_test.py:645: error: Name 'RRef' is not defined
torch/testing/_internal/distributed/rpc/jit/rpc_test.py:651: error: Name 'RRef' is not defined
torch/testing/_internal/distributed/rpc/jit/rpc_test.py:837: error: Name 'Future' is not defined
torch/testing/_internal/distributed/rpc/jit/rpc_test.py:844: error: Name 'Future' is not defined
torch/utils/tensorboard/writer.py:13: error: Cannot find implementation or library stub for module named 'tensorboard.compat'
torch/utils/tensorboard/writer.py:14: error: Cannot find implementation or library stub for module named 'tensorboard.compat.proto.event_pb2'
torch/utils/tensorboard/writer.py:16: error: Cannot find implementation or library stub for module named 'tensorboard.compat.proto'
torch/utils/tensorboard/writer.py:17: error: Cannot find implementation or library stub for module named 'tensorboard.plugins.projector.projector_config_pb2'
torch/utils/tensorboard/writer.py:18: error: Cannot find implementation or library stub for module named 'tensorboard.summary.writer.event_file_writer'
torch/testing/_internal/common_methods_invocations.py:1044: error: Need type annotation for 'tri_large_tests_args' (hint: "tri_large_tests_args: List[<type>] = ...")
torch/testing/_internal/common_methods_invocations.py:1106: error: Need type annotation for 'EXCLUDE_GRADCHECK' (hint: "EXCLUDE_GRADCHECK: Dict[<type>, <type>] = ...")
torch/testing/_internal/common_methods_invocations.py:1108: error: Need type annotation for 'EXCLUDE_GRADGRADCHECK' (hint: "EXCLUDE_GRADGRADCHECK: Dict[<type>, <type>] = ...")
torch/testing/_internal/distributed/rpc/rpc_test.py:13: error: Module 'torch.distributed.rpc' has no attribute 'RRef'
torch/testing/_internal/distributed/rpc/rpc_test.py:13: error: Module 'torch.distributed.rpc' has no attribute '_rref_context_get_debug_info'
torch/testing/_internal/distributed/rpc/rpc_test.py:48: error: Need type annotation for 'VALUE_FUTURE'
torch/testing/_internal/distributed/rpc/rpc_test.py:49: error: Need type annotation for 'DONE_FUTURE'
torch/utils/tensorboard/__init__.py:2: error: Cannot find implementation or library stub for module named 'tensorboard.summary.writer.record_writer'
Found 855 errors in 147 files (checked 328 source files)

After this PR, contributors can start fixing type annotation issues per file or module by:

  1. Deleting the relevant ignore_errors = True entry in mypy.ini
  2. Running $ mypy to show the errors
  3. Fixing things up till $ mypy is clean again

There are still syntax errors left in test/ and in caffe2/. Those can be tackled in parallel as well, and once the syntax errors are fixed, the same strategy can be followed for them (add them to files, add the relevant ignore_errors = True, then fix per module).

Related issue: gh-16574

@rgommers rgommers added the module: typing Related to mypy type annotations label Apr 14, 2020
@rgommers
rgommers requested review from ezyang and zou3519 April 14, 2020 16:35
@facebook-github-bot facebook-github-bot added the oncall: jit Add this issue/PR to JIT oncall triage queue label Apr 14, 2020
@dr-ci

dr-ci Bot commented Apr 14, 2020 •

Copy link
Copy Markdown

💊 Build failures summary and remediations

As of commit 71c7f63 (more details on the Dr. CI page):


  • 1/1 failures introduced in this PR

XLA failure

Job pytorch_xla_linux_bionic_py3_6_clang9_build is failing. Please create an issue with title prefixed by [PT_BREAK] in pytorch/xla and link to to this PR. If you have questions, please reach out to @ailzhang / @dlibenzi / @JackCaoG.


This comment was automatically generated by Dr. CI (expand for details).Follow this link to opt-out of these comments for your Pull Requests.

Please report bugs/suggestions on the GitHub issue tracker.

See how this bot performed.

This comment has been revised 55 times.

@rgommers

Copy link
Copy Markdown
Collaborator Author

Hmm that did its job, it found one issue:

Successfully installed mypy-0.770 mypy-extensions-0.4.3 typed-ast-1.4.1 typing-extensions-3.7.4.2
torch/nn/functional.py:3635: error: syntax error in type comment '(List[int], str, str)'  [syntax]
Found 1 error in 1 file (checked 329 source files)

Fixed in last commit, still figuring out why I didn't see that locally.

@rgommers

rgommers commented Apr 14, 2020 •

Copy link
Copy Markdown
Collaborator Author

Ah it makes more sense now, I ran mypy in an environment with torch and numpy installed, so not seeing these:

Successfully installed mypy-0.770 mypy-extensions-0.4.3 typed-ast-1.4.1 typing-extensions-3.7.4.2
torch/utils/tensorboard/_utils.py:1: error: Skipping analyzing 'numpy': found module but no type hints or library stubs  [import]
torch/_torch_docs.py:107: error: Module has no attribute "abs"  [attr-defined]
torch/_torch_docs.py:126: error: Module has no attribute "acos"  [attr-defined]
torch/_torch_docs.py:148: error: Module has no attribute "add"  [attr-defined]
...

It would be better to move the CI check somewhere that validates an installed torch version. Or do both - repo and installed.

@rgommers

Copy link
Copy Markdown
Collaborator Author

There's also issues that show up depending on file or the set of files you're running. Example:

$ mypy torch/nn/modules/*
torch/nn/modules/activation.pyi: error: Duplicate module named 'torch.nn.modules.activation' (also at 'torch/nn/modules/activation.py')  [misc]
Found 1 error in 1 file (checked 68 source files)

$ mypy torch/nn/modules/activation.py
torch/nn/modules/activation.py:865: error: Module has no attribute "multi_head_attention_forward"  [attr-defined]
torch/nn/modules/activation.py:876: error: Module has no attribute "multi_head_attention_forward"  [attr-defined]
Found 2 errors in 1 file (checked 1 source file)

There's a .pyi stub file which is incomplete, and then there are also type comments in the .py file. The stub file takes precedence if present, so the type comments in the .py file are invisible.

@rgommers rgommers changed the title Fix type annotations and make MyPy run on torch/ WIP: fix type annotations and make MyPy run on torch/ Apr 14, 2020
@rgommers

rgommers commented Apr 14, 2020 •

Copy link
Copy Markdown
Collaborator Author

Oh fun, the JIT and MyPy disagree on what a valid type annotation should look like:

ERROR [0.008s]: test_class_sorting (jit.test_class_type.TestClassType)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "C:\Users\circleci\project\test\jit\test_class_type.py", line 394, in test_class_sorting
    self.checkScript(test, ([Foo(2), Foo(1), Foo(3)],))
  File "C:\Users\circleci\project\build\win_tmp\build\torch\testing\_internal\jit_utils.py", line 393, in checkScript
    frames_up=2)
  File "C:\Users\circleci\project\build\win_tmp\build\torch\testing\_internal\jit_utils.py", line 369, in checkScript
    cu = torch.jit.CompilationUnit(script, _frames_up=frames_up)
  File "C:\Users\circleci\project\build\win_tmp\build\torch\jit\__init__.py", line 1058, in __init__
    self.define(lang, _frames_up=_frames_up + 1)
  File "C:\Users\circleci\project\build\win_tmp\build\torch\jit\__init__.py", line 1063, in define
    self._c.define(lang, rcb)
RuntimeError: 
Expression of type tuple-literal cannot be used in a type expression:
  File "<string>", line 2
def test(li, reverse=False):
    # type: (List[Foo], bool) -> (List[int], List[int])
                                  ~~~~~~~~~~~~~~~~~~~ <--- HERE
    li_sorted = sorted(li)
    ret_sorted = torch.jit.annotate(List[int], [])

without -> (List[int], List[int]) it's a syntax error for MyPy (and those cannot be handled with ignore_errors), with it the JIT gives a RuntimeError.

EDIT: the good news is that that's the only test failure.

@rgommers

Copy link
Copy Markdown
Collaborator Author

The main thing to decide now is what the environment should be for running mypy on the whole code base. Questions:

  • Run on the unbuilt repo, on a develop install, or on an installed version?
  • If develop or install, what options to include (e.g. USE_CUDA=0, USE_MKLDNN=1, USE_DISTRIBUTED=0)?
  • What is the best CI job to tack this onto?

My suggestion would be to make this work on a develop install. Rationale: unbuilt has too many error: Module has no attribute and ignoring them all reduces coverage too much; and using the installed version may (a) reduce the development cycle time, and (b) too much is broken right now to justify adding py.typed, that should be done after things are kind of functional (i.e. no or few ignore_errors = True left).

I'd prefer to start with:

export USE_CUDA=0
export USE_DISTRIBUTED=0
export USE_MKLDNN=0
export USE_FBGEMM=0
export USE_NNPACK=0
export USE_QNNPACK=0
export USE_XNNPACK=0
export USE_NCCL=0

and start enabling those options gradually. Again to increase cycle time and not deal with everything at once.

Regarding best CI job, not sure.

@rgommers

Copy link
Copy Markdown
Collaborator Author

There's about 220 errors left in caffe2/, mostly due to attributes that exist but MyPy cannot find. Caused by weird code constructs like this:

# Bring datatype enums to the main namespace
class DataType:
    pass

def _InitDataType():
    for name, value in caffe2_pb2.TensorProto.DataType.items():
        setattr(DataType, name, value)

_InitDataType()

I'm not sure it's worth spending time on that now, I think just blanket ignores for caffe2.proto and caffe2.python is the way to go in this PR.

@ezyang

ezyang commented Apr 15, 2020

Copy link
Copy Markdown
Contributor

cc @malmaud

@ezyang

ezyang commented Apr 15, 2020

Copy link
Copy Markdown
Contributor

The stub file takes precedence if present, so the type comments in the .py file are invisible.

Going forward, we can eliminate these problems by inlining the stubs into the py file. Also something that can be done incrementally (except for the _C binding bits; those we'll have to still write stubs for.)

@ezyang

ezyang commented Apr 15, 2020

Copy link
Copy Markdown
Contributor

without -> (List[int], List[int]) it's a syntax error for MyPy (and those cannot be handled with ignore_errors), with it the JIT gives a RuntimeError.

Let's disable this test and add another JIT issue for it.

@ezyang

ezyang commented Apr 15, 2020

Copy link
Copy Markdown
Contributor

The main thing to decide now is what the environment should be for running mypy on the whole code base

I agree with develop. However, that means that having the mypy job in quickcheck is not good because now we have to build PyTorch first before we can run checks; it's probably better to roll up the mypy check with an existing CI job. Maybe we should just run mypy as part of ALL the jobs (which means that you'll end up covering the CPU and the CUDA cases).

In an ideal world, the set of bindings we make available would be invariant no matter what build configuration you are in, so no matter if you build with some build option or without, mypy will typecheck the same. I don't know how true that is today.

I'm not sure it's worth spending time on that now, I think just blanket ignores for caffe2.proto and caffe2.python is the way to go in this PR.

I agree, blanket ignoring sounds the best.

@ezyang

ezyang commented Apr 15, 2020 •

Copy link
Copy Markdown
Contributor

Changes in the code LGTM, looking forward to merging this!

@malmaud

malmaud commented Apr 15, 2020

Copy link
Copy Markdown
Contributor

It LGTM, but I only skimmed it so don't hold me to anything :)
Thanks for helping with the PyTorch typing initiative!

Note: this will likely fail in CI, due to the reason given in the
test_doc_examples comment.
@rgommers

rgommers commented Apr 21, 2020 •

Copy link
Copy Markdown
Collaborator Author

Okay, adding it to the test suite as test_run_mypy works better:

Apr 21 12:13:25   test_doc_examples (__main__.TestTypeHints) ... Success: no issues found in 1 source file
Apr 21 12:13:26 ok (9.875s)
Apr 21 12:13:50   test_run_mypy (__main__.TestTypeHints) ... Success: no issues found in 967 source files
Apr 21 12:13:51 ok (25.079s)
Apr 21 12:14:00   test_type_hint_examples (__main__.TestTypeHints) ... Success: no issues found in 1 source file
Apr 21 12:14:00 ok (9.495s)

The one XLA build failure is unrelated. pr/caffe2-py3.6-devtoolset7-rocmrpm-centos7-test is still running, assuming that passes as well (EDIT: that job timed out, unrelated failure), this should be good to merge now.

@rgommers rgommers changed the title WIP: fix type annotations and make MyPy run on torch/ Fix type annotations and make MyPy run on torch/ Apr 21, 2020
@ezyang

ezyang commented Apr 21, 2020

Copy link
Copy Markdown
Contributor

install in /.circleci/docker/common/install_travis_python.sh

This is OK, but now you have to rebuild the docker images per the instructions at https://github.com/pytorch/pytorch/wiki/Docker-image-build-on-CircleCI

I'm going to land this anyway for now but it will mean that our actually deployed images are out of sync with what the script says they are.

@facebook-github-bot facebook-github-bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ezyang is landing this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

@rgommers

Copy link
Copy Markdown
Collaborator Author

This is OK, but now you have to rebuild the docker images per the instructions at https://github.com/pytorch/pytorch/wiki/Docker-image-build-on-CircleCI

Will do. The tests already ran in CI though, so there may be another (unpinned probably) pip install mypy hiding somewhere. I'll see if I can hunt that down.

@rgommers

Copy link
Copy Markdown
Collaborator Author

Will do. The tests already ran in CI though, so there may be another (unpinned probably) pip install mypy hiding somewhere. I'll see if I can hunt that down.

That was in .jenkins/pytorch/test.sh. Indeed unpinned. I hadn't expected it to be in .jenkins, but it works - so I think let's remove it from .circleci/docker/common/install_travis_python.sh again.

I can pin it in .jenkins/pytorch/test.sh or wait till the first time it blows up. I'd suggest the former.

@ezyang

ezyang commented Apr 21, 2020

Copy link
Copy Markdown
Contributor

I can pin it in .jenkins/pytorch/test.sh or wait till the first time it blows up.

Yeah let's pin it.

@facebook-github-bot facebook-github-bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ezyang is landing this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

@ezyang

ezyang commented Apr 22, 2020

Copy link
Copy Markdown
Contributor

Looks like there are some internal failures that are causing problems.

First, it looks like the Caffe2 test files cannot validly use the dot-qualified import as in internal CI their PYTHON_PATH is setup strangely:


Traceback (most recent call last):
  File "<string>", line 37, in <module>
  File "<string>", line 35, in __run
  File "/usr/local/fbcode/platform007/lib/python3.7/runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "/usr/local/fbcode/platform007/lib/python3.7/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/data/sandcastle/boxes/eden-trunk-hg-fbcode-fbsource/fbcode/buck-out/dev/gen/caffe2/caffe2/quantization/server/batch_matmul_dnnlowp_op_test#binary,link-tree/__fb_test_main__.py", line 895, in <module>
    sys.exit(main(sys.argv))
  File "/data/sandcastle/boxes/eden-trunk-hg-fbcode-fbsource/fbcode/buck-out/dev/gen/caffe2/caffe2/quantization/server/batch_matmul_dnnlowp_op_test#binary,link-tree/__fb_test_main__.py", line 891, in main
    return MainProgram(sys.argv).run()
  File "/data/sandcastle/boxes/eden-trunk-hg-fbcode-fbsource/fbcode/buck-out/dev/gen/caffe2/caffe2/quantization/server/batch_matmul_dnnlowp_op_test#binary,link-tree/__fb_test_main__.py", line 717, in run
    test_suite = self.load_tests()
  File "/data/sandcastle/boxes/eden-trunk-hg-fbcode-fbsource/fbcode/buck-out/dev/gen/caffe2/caffe2/quantization/server/batch_matmul_dnnlowp_op_test#binary,link-tree/__fb_test_main__.py", line 700, in load_tests
    suite = loader.load_all()
  File "/data/sandcastle/boxes/eden-trunk-hg-fbcode-fbsource/fbcode/buck-out/dev/gen/caffe2/caffe2/quantization/server/batch_matmul_dnnlowp_op_test#binary,link-tree/__fb_test_main__.py", line 473, in load_all
    __import__(module_name, level=0)
  File "/data/sandcastle/boxes/eden-trunk-hg-fbcode-fbsource/fbcode/buck-out/dev/gen/caffe2/caffe2/quantization/server/batch_matmul_dnnlowp_op_test#binary,link-tree/caffe2/caffe2/quantization/server/batch_matmul_dnnlowp_op_test.py", line 11, in <module>
    from .dnnlowp_test_utils import (
ModuleNotFoundError: No module named 'caffe2.caffe2.quantization.server.dnnlowp_test_utils'

The second weirdness is that these changes have started causing some of our internal typechecking builds (using our internal typechecker called pyre, don't ask...) to start twinging. Here are two occurrences:

Incompatible parameter type [6]: Expected `Tensor` for 1st positional only parameter to call `nn.init.zeros_` but got `typing.Optional[Tensor]`.

code looks like:

from functools import wraps
from typing import Any, Callable

import torch
from torch import Tensor, nn
from torch.utils.data import DataLoader, TensorDataset


PREDICT_BATCH_SIZE = 1024


def uniform_weight_initializer(module: nn.Module, lower: float, upper: float) -> None:
    """
    Initialize weights from Unif(lower, upper). Initialize biases as zero.
    Initialization is performed in-place.
    """
    if isinstance(module, nn.Linear):
        nn.init.uniform_(module.weight, lower, upper)
        if module.bias is not None:
            nn.init.zeros_(module.bias) # ERROR HERE

and

Incompatible parameter type [6]: Expected `Tensor` for 1st positional only parameter to call `init.uniform_` but got `Optional[Parameter]`.

context

    base_root_node_embedding: Optional[Parameter]
...
        if options.remove_root_node_features:
            self.base_root_node_embedding = Parameter(
                torch.Tensor(options.node_embedding_dim)
            )
            bound = 1 / math.sqrt(options.node_embedding_dim)
            init.uniform_(self.base_root_node_embedding, -bound, bound) # error here

I can get in touch with the downstream teams here to see what appropriate remediations are.

Some other ones:

[aerl_experimental/bae/models/utils.py:22:27] Incompatible parameter type [6]: Expected `Tensor` for 1st positional only parameter to call `nn.init.zeros_` but got `typing.Optional[Tensor]`.
[caffe2/torch/fb/training_toolkit/common/proxy_initializer_materializer.py:33:8] Incompatible return type [7]: Expected `typing.Callable[[torch.Tensor], None]` but got `partial[torch.Tensor]`.
Type `typing.Callable[[torch.Tensor], None]` expected on line 35, specified on line 20.
[caffe2/torch/fb/training_toolkit/common/proxy_initializer_materializer.py:37:8] Incompatible return type [7]: Expected `typing.Callable[[torch.Tensor], None]` but got `partial[torch.Tensor]`.
Type `typing.Callable[[torch.Tensor], None]` expected on line 37, specified on line 20.
[deeplearning/projects/research-handtracking/pytorch/problems/hhi/tasks/two_hand_jlp_task.py:164:42] Incompatible parameter type [6]: Expected `torch.Tensor` for 1st positional only parameter to call `nn.init.constant_` but got `Optional[torch.Tensor]`.[si/dec/pytorch/gnn/gnn.py:183:26] Incompatible parameter type [6]: Expected `Tensor` for 1st positional only parameter to call `init.uniform_` but got `Optional[Parameter]`.

@ezyang

ezyang commented Apr 22, 2020

Copy link
Copy Markdown
Contributor

I should have some time tomorrow to look a little, but not too much. If some of these you can predict fixes for without further info, that would be great.

@rgommers

Copy link
Copy Markdown
Collaborator Author

The second weirdness is that these changes have started causing some of our internal typechecking builds (using our internal typechecker called pyre, don't ask...) to start twinging.

Hmm, I'd expect more such conflicts to occur when people start tackling the remaining O(1000) mypy errors. I just tried pip install pyre_check, but it doesn't even install cleanly (complains about PyYAML version).

Looking into the errors now.

Those were correct, but due to a weirdness in how PYTHONPATH is set
up in caffe2's internal CI, that caused an issue.

Mypy on the other hand complains about absolute imports, so go for
fully-qualified imports here.
@rgommers

rgommers commented Apr 22, 2020 •

Copy link
Copy Markdown
Collaborator Author
    if isinstance(module, nn.Linear):
        nn.init.uniform_(module.weight, lower, upper)
        if module.bias is not None:
            nn.init.zeros_(module.bias) # ERROR HERE

This looks like a MyPy bug, python/mypy#2608 (EDIT: I assumed pyre has the same bug, will see if I can narrow that down). if module.bias is not None: on the line above where the error occurs should make it narrow the type from Optional[Tensor] to Tensor, but it fails to do so.

One workaround is to add assert module.bias is not None right above the zeros_ call.

The second error (uniform_) is very similar, but that code snippet is harder for MyPy to parse; another assert would be justified.

The rest of the errors also look similar. @ezyang is it doable to add those asserts in the code that's throwing errors? I don't see a good workaround within PyTorch.

EDIT 2: Pyre has a similar open issue (meta/pyre-check#197), except they disagree it's a bug - even with the assert they don't want to do type narrowing. A suggested fix is to annotate the attribute as Final, but that's only available in Python 3.8. The workarounds are (a) using pyre-ignore[16], (b) assigning the code to an intermediate variable (see meta/pyre-check#197 (comment)), or (c) pinning pyre_check to v0.0.28 (the last version that worked "less strictly correct but more useful").

The annotations within torch.nn all look correct; Parameter is a subclass of Tensor and functions annotated as Tensor will accept Parameter as a subtype. Side note: that did make me realize that tensor-like objects that use __torch_function__ will be a problem there. We can wait with dealing with that for a while I think.

@facebook-github-bot facebook-github-bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ezyang has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

@ezyang

ezyang commented Apr 22, 2020

Copy link
Copy Markdown
Contributor

Good news, I got in touch with the upstream authors here and they will fix their code (or agreed to let me pyre-fixme it for now), so no changes needed in PyTorch.

Pinning pyre isn't going to do much good since FB is running on bleeding edge Pyre. Though, perhaps we should also start running Pyre in open source. Not for this PR though.

@rgommers

Copy link
Copy Markdown
Collaborator Author
import torch
from torch import Tensor, nn


def func(module: nn.Module) -> Tensor:
    res = torch.tensor([])
    #if isinstance(module, nn.Linear):
    nn.init.uniform_(module.weight, 0, 1)
    #if module.bias is not None:
    res = nn.init.zeros_(module.bias)

    return res


module = nn.Linear(10, 30, bias=False)
t1 = torch.randn(256, 10)
t2 = module(t1)
res = func(module)

gives the same errors with both mypy and pyre:

typecheck_issue.py:8: error: Argument 1 to "uniform_" has incompatible type "Union[Tensor, Module[Any]]"; expected "Tensor"
typecheck_issue.py:10: error: Argument 1 to "zeros_" has incompatible type "Union[Tensor, Module[Any]]"; expected "Tensor"

Uncommenting the first if-statements resolves those errors:

    if isinstance(module, nn.Linear):
        nn.init.uniform_(module.weight, 0, 1)
        #if module.bias is not None:
        res = nn.init.zeros_(module.bias)

and mypy and pyre are both happy, even though that code will crash if you run it. Versions: mypy 0.770, pyre-check 0.0.46.

Uncommenting the second if-statement makes no difference for type checking.

Using reveal_type on:

    if isinstance(module, nn.Linear):
        nn.init.uniform_(module.weight, 0, 1)
        reveal_type(module)
        reveal_type(module.bias)
        if module.bias is not None:
            res = nn.init.zeros_(module.bias)

shows:

typecheck_issue.py:9: note: Revealed type is 'torch.nn.modules.linear.Linear'
typecheck_issue.py:10: note: Revealed type is 'torch.nn.parameter.Parameter'

Parameter is indeed how Linear.bias is annotated in linear.pyi. That should actually be Optional[Parameter] (although the annotation may have been on purpose (?), done by @malmaud in gh-19089). If I change it to that, I get:

error: Argument 1 to "zeros_" has incompatible type "Optional[Parameter]"; expected "Tensor"

with mypy. And with pyre:

Incompatible parameter type [6]: Expected `Tensor` for 1st positional only parameter to call `nn.init.zeros_` but got `typing.Optional[nn.parameter.Parameter]`.

The pyre error can indeed be suppressed with:

nn.init.zeros_(module.bias)  # pyre-ignore[6]

Now for the second workaround:

        if module.bias is not None:
            bias = module.bias
            res = nn.init.zeros_(bias)

does not work (with pyre 0.0.46).

I also tried pyre 0.0.28, but that gives a ton of other errors, so I expect that's a nonstarter.

tl;dr use # pyre-ignore[6]

@rgommers

Copy link
Copy Markdown
Collaborator Author

Good news, I got in touch with the upstream authors here and they will fix their code (or agreed to let me pyre-fixme it for now), so no changes needed in PyTorch.

Great! I was just in the middle of posting my giant comment above, glad we came to the same conclusion.

@ezyang

ezyang commented Apr 22, 2020

Copy link
Copy Markdown
Contributor

@rgommers BTW, I heard we can get Final from typing_extensions prior to Python 3.8; let's use it!

@ezyang

ezyang commented Apr 22, 2020

Copy link
Copy Markdown
Contributor

Don't worry about the merge conflict, I will take care of it internally

@facebook-github-bot

Copy link
Copy Markdown
Contributor

@ezyang merged this pull request in 78d5707.

facebook-github-bot pushed a commit that referenced this pull request Jan 19, 2021
Summary:
This PR helps with #50513 by reducing the complexity of our `mypy` test suite and making it easier to reproduce on the command line. Previously, to reproduce how `mypy` was actually run on tracked source files (ignoring the doctest typechecking) in CI, you technically needed to run 9 different commands with various arguments:
```
$ mypy --cache-dir=.mypy_cache/normal --check-untyped-defs --follow-imports silent
$ mypy --cache-dir=.mypy_cache/examples --follow-imports silent --check-untyped-defs test/type_hint_tests/module_list.py
$ mypy --cache-dir=.mypy_cache/examples --follow-imports silent --check-untyped-defs test/type_hint_tests/namedtuple.py
$ mypy --cache-dir=.mypy_cache/examples --follow-imports silent --check-untyped-defs test/type_hint_tests/opt_size.py
$ mypy --cache-dir=.mypy_cache/examples --follow-imports silent --check-untyped-defs test/type_hint_tests/size.py
$ mypy --cache-dir=.mypy_cache/examples --follow-imports silent --check-untyped-defs test/type_hint_tests/tensor_copy.py
$ mypy --cache-dir=.mypy_cache/examples --follow-imports silent --check-untyped-defs test/type_hint_tests/torch_cuda_random.py
$ mypy --cache-dir=.mypy_cache/examples --follow-imports silent --check-untyped-defs test/type_hint_tests/torch_optim.py
$ mypy --cache-dir=.mypy_cache/strict --config mypy-strict.ini
```
Now you only have to run 2 much simpler commands:
```
$ mypy
$ mypy --config mypy-strict.ini
```
One reason this is useful is because it will make it easier to integrate PyTorch's `mypy` setup into editors (remaining work on this to be done in a followup PR).

Also, as shown in the test plan, this also reduces the time it takes to run `test/test_type_hints.py` incrementally, by reducing the number of times `mypy` is invoked while still checking the same set of files with the same configs.

(Because this PR merges `test_type_hint_examples` (added in #34595) into `test_run_mypy` (added in #36584), I've added some people involved in those PRs as reviewers, in case there's a specific reason they weren't combined in the first place.)

Pull Request resolved: #50631

Test Plan:
Run this twice (the first time is to warm the cache):
```
$ python test/test_type_hints.py -v
```

- *Before:*
  ```
  test_doc_examples (__main__.TestTypeHints)
  Run documentation examples through mypy. ... ok
  test_run_mypy (__main__.TestTypeHints)
  Runs mypy over all files specified in mypy.ini ... ok
  test_run_mypy_strict (__main__.TestTypeHints)
  Runs mypy over all files specified in mypy-strict.ini ... ok
  test_type_hint_examples (__main__.TestTypeHints)
  Runs mypy over all the test examples present in ... ok

  ----------------------------------------------------------------------
  Ran 4 tests in 5.090s

  OK
  ```
  You can also just run `mypy` to see how many files it checks:
  ```
  $ mypy --cache-dir=.mypy_cache/normal --check-untyped-defs --follow-imports silent
  Success: no issues found in 1192 source files
  ```
- *After:*
  ```
  test_doc_examples (__main__.TestTypeHints)
  Run documentation examples through mypy. ... ok
  test_run_mypy (__main__.TestTypeHints)
  Runs mypy over all files specified in mypy.ini ... ok
  test_run_mypy_strict (__main__.TestTypeHints)
  Runs mypy over all files specified in mypy-strict.ini ... ok

  ----------------------------------------------------------------------
  Ran 3 tests in 2.404s

  OK
  ```
  Now `mypy` checks 7 more files, which is the number in `test/type_hint_tests`:
  ```
  $ mypy
  Success: no issues found in 1199 source files
  ```

Reviewed By: zou3519

Differential Revision: D25932660

Pulled By: samestep

fbshipit-source-id: 26c6f00f338e7b44954e5ed89522ce24e2fdc5f0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Merged module: typing Related to mypy type annotations oncall: jit Add this issue/PR to JIT oncall triage queue open source

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants