Huggingface AutoTokenizer cannot be referenced when importing Transformers - huggingface-transformers

I am trying to import AutoTokenizer and AutoModelWithLMHead, but I am getting the following error:
ImportError: cannot import name 'AutoTokenizer' from partially initialized module 'transformers' (most likely due to a circular import)
First, I install transformers: pip install transformers then implemented the following code:
from transformers import AutoTokenizer, AutoModelWithLMHead
tokenizer = AutoTokenizer.from_pretrained("t5-base")
model = AutoModelWithLMHead.from_pretrained("t5-base")

For anyone who comes across a problem around circular import, this could be due to the naming convention of your .py file. Changing my file name solved the issue as there might be a file in my Python lib folder with similar naming conventions.

Related

Issue in importing gen package

I am trying to import gen package in main.go file.
import ("golang.org/x/text/internal/gen")
But I am facing following error and still I haven't find solution to this:
main.go:7:2: use of internal package golang.org/x/text/internal/gen not allowed
Could someone help me to solve this problem. Thank you.

Import from the same package, using package name

I've added dependency to https://github.com/sjwhitworth/golearn in Golang project. I've tried to build application, however I am getting error from one of the classes from golearn - this one: https://github.com/sjwhitworth/golearn/blob/master/base/dataframe_go.go : undefined: base. I've tried to find what is the base package refering to. There is no imported package base in this file so it looks like it is import from the same package but using the package name. I mean, dataframe_go.go is in the same package (base) where is the imported struct (FixedDataGrid). How to solve this import issue?

Error in "import org.car2x.veins.subprojects.veins_inet.VeinsInetManager" SimuLTE's Highway.ned file

I tried to install simuLTE and followed the versions according to https://github.com/inet-framework/simulte/releases. After downloading I imported the project in Omnet++(I build the INET3.6.6 before importing simuLTE )
Then I imported veins and tried to import veins into simuLTE according to the instructions given in https://simulte.com/add_veins.html
While running (after building the project) the project lte--> simulation --> card --> omnetpp.ini, I am getting the error in "Highway.ned" file. The screenshot of the errors is attached. I tried different paths in the "import org.car2x.veins.subprojects.veins_inet.VeinsInetManager" but i am getting error.
//import org.car2x.veins.subprojects.veins_inet.VeinsInetManager;
import veins.veins_inet.VeinsInetManager;
The error is: cannot resolve module type 'VeinsInetManager'(not in the loaded NED file?)
What is the reason of this error, where am I going wrong?
First you have to check if the project is referenced.
Project->Propierties->Project References.
Second if this doesn't works use a import with *.
Like import org.car2x.veins.subprojects.veins_inet.*;
Third check versions. Maybe not compatible.

python lambda not able to import user defined modules

I have a python lambda which turns out to be a bit long so we decided to split it into modules. and now when i try to import the module in the lambda_handler its seems to be giving following error
Unable to import module 'defghi': attempted relative import with no known parent package
abc.py which has got lambda_handler in it, is trying to import the defghi.py methods as follows
from defghi import some_method_1, some_method_2
tried this as well
from .defghi import some_method_1, some_method_2
both the files are in the same directory
any sort of help would be appreciated, Thanks in adavance
Finally got that working it was the build scripts which where causing the issue in my project.
The build script which created the zip file where expecting only one .py file in the directory which was a problem. So the zip created never had other files which then gave error cannot import.
So to answer the question its perfectly fine to split the big lambdas into modules and keep them a bit readable and import into the main lambda_handler the required modules.

How to include external file in Go?

I'm using LiteIDE for Go. I have a Go file located here:
/Users/username/go/src/src/Helper/Helper.go
When I include the file using:
import "../Helper"
I get this error:
can't load package: /Users/username/go/src/src/projectA/main.go:4:8:
local import "../Helper" in non-local package
Any ideas what I'm doing wrong?
You import packages by import path. For package Helper, located in $GOPATH/src/Helper/, use:
import "Helper"
While they can work in some cases, relative paths aren't supported by the go toolchain, and are discouraged.

Resources