> ## 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](/join-use-case/model-optimization#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`, `interpret`, `lifelines`, `lightgbm`, `peft`, `pycox`, `pytorch_forecasting`, `sklearn`, `sksurv`, `timm`, `torch`, `torchvision`, `transformers`, `xgboost` |
| `cv`        | `keypoint_detection`, `object_detection`, `semantic_segmentation`                                                                                              | `peft`, `torch`, `torchvision`, `transformers`                                                                                                                           |
| `nlp`       | `causal_language_modeling`, `embeddings`, `masked_language_modeling`, `sentence_pair_classification`, `seq2seq`, `text_classification`, `token_classification` | `torch`, `transformers`                                                                                                                                                  |

Every task may also import `collections` and `math`.

Across all tasks, these are the only packages a model file may import at all: `catboost`, `collections`, `interpret`, `lifelines`, `lightgbm`, `math`, `peft`, `pycox`, `pytorch_forecasting`, `sklearn`, `sksurv`, `timm`, `torch`, `torchvision`, `transformers`, `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: collections, math, peft, torch, torchvision, transformers.
  ```

  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`.
</Note>
