> ## Documentation Index
> Fetch the complete documentation index at: https://docs.tracebloc.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Allowed imports

> Which Python packages a model file may import for each task, and what happens when an upload imports something else.

When you upload a model, tracebloc reads the imports in your model file before it accepts the upload. Your model trains inside a training image in the secure environment that holds the use case's data, and each training image installs only the packages its tasks need. A model that imports a package its image does not have would fail there, after it was already scheduled to train. The upload check catches this up front and refuses the model instead.

## How the check decides

Tasks are grouped into three **task families**, and each family has its own training images. The task your model file declares in its `category` variable (see [Mandatory variables](https://docs.tracebloc.io/join-use-case/model-optimization.md#mandatory-variables)) decides the family. The family decides which packages the model file may import.

* **Only the top-level package counts.** `import torch.nn as nn` and `from torch.utils.data import DataLoader` are both `torch`.
* **Your own files are always allowed.** In a zipped, multi-file upload, your files may import each other. The rule applies to every other import.

## Packages per task family

| Task family | Tasks (the `category` your model file declares) | Packages a model file may import |
| - | - | - |
| `base` | `image_classification`, `tabular_classification`, `tabular_regression`, `time_series_classification`, `time_series_forecasting`, `time_to_event_prediction` | `catboost`, `einops`, `interpret`, `lifelines`, `lightgbm`, `numpy`, `peft`, `pycox`, `pytorch_forecasting`, `sklearn`, `sksurv`, `timm`, `torch`, `torchvision`, `transformers`, `xgboost` |
| `cv` | `keypoint_detection`, `object_detection`, `semantic_segmentation` | `einops`, `numpy`, `peft`, `torch`, `torchvision`, `transformers` |
| `nlp` | `causal_language_modeling`, `embeddings`, `masked_language_modeling`, `multi_label_text_classification`, `sentence_pair_classification`, `seq2seq`, `text_classification`, `text_regression`, `token_classification` | `einops`, `numpy`, `torch`, `transformers` |

Every task may also import `__future__`, `abc`, `collections`, `copy`, `dataclasses`, `enum`, `functools`, `itertools`, `math`, `numbers`, `operator`, `typing` and `warnings`.

Across all tasks, these are the only packages a model file may import at all: `__future__`, `abc`, `catboost`, `collections`, `copy`, `dataclasses`, `einops`, `enum`, `functools`, `interpret`, `itertools`, `lifelines`, `lightgbm`, `math`, `numbers`, `numpy`, `operator`, `peft`, `pycox`, `pytorch_forecasting`, `sklearn`, `sksurv`, `timm`, `torch`, `torchvision`, `transformers`, `typing`, `warnings`, `xgboost`.

## When an upload imports something else

* **A package no task may import** (for example `tensorflow`, `requests` or `os`) is refused whatever the task.
* **A package another family allows but yours does not** is refused. The message names the task family, the imports its training image does not provide, and every package a model for that task may import. For example, an object detection model that imports scikit-learn is refused with a message that begins:

  ```text theme={null}
  Model imports sklearn, which the 'cv' training image for object_detection models does not provide. A object_detection model may import: __future__, abc, collections, copy, dataclasses, einops, enum, functools, itertools, math, numbers, numpy, operator, peft, torch, torchvision, transformers, typing, warnings.
  ```

  To fix it, remove the import, or rewrite that part of the model with a package from your task's list.
* **A `category` the check does not recognise** is not held to any family. The upload is recorded, not refused by this check, but it may still import only the packages allowed across all tasks.
* **If the check itself cannot run**, the upload is refused with *"The model's imports could not be checked against its task family. Please retry the upload; if this persists, contact support."* Nothing is wrong with your model; retry the upload.

> [!NOTE]
>
> The task `tabular_classification` was once called `generic_classification`. A model file that still declares `category = "generic_classification"` is checked as `tabular_classification`.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.