This is a context manager to temporarily change transformers modules logging level to the desired value and have it restored to the original setting at the end of the scope. Example: ```python with LoggingLevel(logging.INFO): AutoModel.from_pretrained("openai-community
(level)
| 1451 | |
| 1452 | @contextlib.contextmanager |
| 1453 | def LoggingLevel(level): |
| 1454 | """ |
| 1455 | This is a context manager to temporarily change transformers modules logging level to the desired value and have it |
| 1456 | restored to the original setting at the end of the scope. |
| 1457 | |
| 1458 | Example: |
| 1459 | |
| 1460 | ```python |
| 1461 | with LoggingLevel(logging.INFO): |
| 1462 | AutoModel.from_pretrained("openai-community/gpt2") # calls logger.info() several times |
| 1463 | ``` |
| 1464 | """ |
| 1465 | orig_level = transformers_logging.get_verbosity() |
| 1466 | try: |
| 1467 | transformers_logging.set_verbosity(level) |
| 1468 | yield |
| 1469 | finally: |
| 1470 | transformers_logging.set_verbosity(orig_level) |
| 1471 | |
| 1472 | |
| 1473 | @contextlib.contextmanager |
no outgoing calls
no test coverage detected