<commit_before>from typing import cast, TypeVar
import eagerpy as ep

from ..types import Bounds
from .base import Model


T = TypeVar("T")


class Foolbox2Model(Model):
    def __init__(self, model):
        self._model = model

    @property
    def bounds(self) -> Bounds:
        return cast(Bounds, self._model.bounds())

    def __call__(self, inputs: T) -> T:
        x, restore_type = ep.astensor_(inputs)
        y: ep.types.NativeTensor = self._model.forward(x.numpy())
        z = ep.astensor(y)
        return restore_type(z)

    @property
    def data_format(self) -> str:
        channel_axis = self._model.channel_axis()
        if channel_axis == 1:
            data_format = "channels_first"
        elif channel_axis == 3:
            data_format = "channels_last"
        return data_format
<commit_msg>fixed Foolbox2Model<commit_after>from typing import cast, TypeVar
import eagerpy as ep

from ..types import Bounds
from .base import Model


T = TypeVar("T")


class Foolbox2Model(Model):
    def __init__(self, model):
        self._model = model

    @property
    def bounds(self) -> Bounds:
        return cast(Bounds, self._model.bounds())

    def __call__(self, inputs: T) -> T:
        x, restore_type = ep.astensor_(inputs)
        y = self._model.forward(x.numpy())
        z = ep.from_numpy(x, y)
        return restore_type(z)

    @property
    def data_format(self) -> str:
        channel_axis = self._model.channel_axis()
        if channel_axis == 1:
            data_format = "channels_first"
        elif channel_axis == 3:
            data_format = "channels_last"
        return data_format

{'fraction_non_alphanumeric': 0.10403916768665851, 'fraction_numerical': 0.004283965728274173, 'mean_word_length': 2.5085836909871246, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2631403', 'n_tokens_mistral': 515, 'n_tokens_neox': 500, 'n_words': 133}