Error importing LayoutLMv2ForTokenClassification from HuggingFace
I am trying to run this demo notebook on colab and I am getting the following pytorch error when importing LayoutLMv2ForTokenClassification:
from transformers import LayoutLMv2ForTokenClassification

Error:
ModuleNotFoundError                       Traceback (most recent call last)
~\PycharmProjects\playground\camelot\camelotenv\lib\site-packages\transformers\utils\import_utils.py in _get_module(self, module_name)
   1029         try:
-&gt; 1030             return importlib.import_module(&quot;.&quot; + module_name, self.__name__)
   1031         except Exception as e:

~\AppData\Local\Programs\Python\Python39\lib\importlib\__init__.py in import_module(name, package)
    126             level += 1
--&gt; 127     return _bootstrap._gcd_import(name[level:], package, level)
    128 

~\AppData\Local\Programs\Python\Python39\lib\importlib\_bootstrap.py in _gcd_import(name, package, level)

~\AppData\Local\Programs\Python\Python39\lib\importlib\_bootstrap.py in _find_and_load(name, import_)

~\AppData\Local\Programs\Python\Python39\lib\importlib\_bootstrap.py in _find_and_load_unlocked(name, import_)

~\AppData\Local\Programs\Python\Python39\lib\importlib\_bootstrap.py in _load_unlocked(spec)

~\AppData\Local\Programs\Python\Python39\lib\importlib\_bootstrap_external.py in exec_module(self, module)

~\AppData\Local\Programs\Python\Python39\lib\importlib\_bootstrap.py in _call_with_frames_removed(f, *args, **kwds)

~\PycharmProjects\playground\camelot\camelotenv\lib\site-packages\transformers\models\layoutlmv2\modeling_layoutlmv2.py in &lt;module&gt;
     48     import detectron2
---&gt; 49     from detectron2.modeling import META_ARCH_REGISTRY
     50 

~\PycharmProjects\playground\camelot\camelotenv\lib\site-packages\detectron2\modeling\__init__.py in &lt;module&gt;
     19 )
---&gt; 20 from .meta_arch import (
     21     META_ARCH_REGISTRY,

~\PycharmProjects\playground\camelot\camelotenv\lib\site-packages\detectron2\modeling\meta_arch\__init__.py in &lt;module&gt;
      5 
----&gt; 6 from .panoptic_fpn import PanopticFPN
      7 

~\PycharmProjects\playground\camelot\camelotenv\lib\site-packages\detectron2\modeling\meta_arch\panoptic_fpn.py in &lt;module&gt;
     13 from .build import META_ARCH_REGISTRY
---&gt; 14 from .rcnn import GeneralizedRCNN
     15 from .semantic_seg import build_sem_seg_head

~\PycharmProjects\playground\camelot\camelotenv\lib\site-packages\detectron2\modeling\meta_arch\rcnn.py in &lt;module&gt;
     17 from ..proposal_generator import build_proposal_generator
---&gt; 18 from ..roi_heads import build_roi_heads
     19 from .build import META_ARCH_REGISTRY

~\PycharmProjects\playground\camelot\camelotenv\lib\site-packages\detectron2\modeling\roi_heads\__init__.py in &lt;module&gt;
     14 )
---&gt; 15 from .roi_heads import (
     16     ROI_HEADS_REGISTRY,

~\PycharmProjects\playground\camelot\camelotenv\lib\site-packages\detectron2\modeling\roi_heads\roi_heads.py in &lt;module&gt;
     16 from ..matcher import Matcher
---&gt; 17 from ..poolers import ROIPooler
     18 from ..proposal_generator.proposal_utils import add_ground_truth_to_proposals

~\PycharmProjects\playground\camelot\camelotenv\lib\site-packages\detectron2\modeling\poolers.py in &lt;module&gt;
      9 from detectron2.structures import Boxes
---&gt; 10 from detectron2.utils.tracing import assert_fx_safe
     11 

~\PycharmProjects\playground\camelot\camelotenv\lib\site-packages\detectron2\utils\tracing.py in &lt;module&gt;
      3 import torch
----&gt; 4 from torch.fx._symbolic_trace import _orig_module_call
      5 from torch.fx._symbolic_trace import is_fx_tracing as is_fx_tracing_current

ModuleNotFoundError: No module named 'torch.fx._symbolic_trace'

The above exception was the direct cause of the following exception:

RuntimeError                              Traceback (most recent call last)
&lt;ipython-input-36-b5a73c6d310a&gt; in &lt;module&gt;
      4 device_ids = [0,1]
      5 
----&gt; 6 from transformers import LayoutLMv2ForTokenClassification, TrainingArguments, Trainer
      7 from datasets import load_metric
      8 import numpy as np

~\AppData\Local\Programs\Python\Python39\lib\importlib\_bootstrap.py in _handle_fromlist(module, fromlist, import_, recursive)

~\PycharmProjects\playground\camelot\camelotenv\lib\site-packages\transformers\utils\import_utils.py in __getattr__(self, name)
   1019         elif name in self._class_to_module.keys():
   1020             module = self._get_module(self._class_to_module[name])
-&gt; 1021             value = getattr(module, name)
   1022         else:
   1023             raise AttributeError(f&quot;module {self.__name__} has no attribute {name}&quot;)

~\PycharmProjects\playground\camelot\camelotenv\lib\site-packages\transformers\utils\import_utils.py in __getattr__(self, name)
   1018             value = self._get_module(name)
   1019         elif name in self._class_to_module.keys():
-&gt; 1020             module = self._get_module(self._class_to_module[name])
   1021             value = getattr(module, name)
   1022         else:

~\PycharmProjects\playground\camelot\camelotenv\lib\site-packages\transformers\utils\import_utils.py in _get_module(self, module_name)
   1030             return importlib.import_module(&quot;.&quot; + module_name, self.__name__)
   1031         except Exception as e:
-&gt; 1032             raise RuntimeError(
   1033                 f&quot;Failed to import {self.__name__}.{module_name} because of the following error (look up to see its&quot;
   1034                 f&quot; traceback):\n{e}&quot;

RuntimeError: Failed to import transformers.models.layoutlmv2.modeling_layoutlmv2 because of the following error (look up to see its traceback):
No module named 'torch.fx._symbolic_trace'

Can anyone please help?
Thanks!

This is issue from importing torch.fix flag check for symbolic trace and new commit error of detectron (use 5aeb252b194b93dc2879b4ac34bc51a31b5aee13 this checkout and install )
for temporary work
or clone pytorch with new commit
