





import numpy as np
import torch
from imwatermark import WatermarkEncoder


# Copied from https://github.com/Stability-AI/generative-models/blob/613af104c6b85184091d42d374fef420eddb356d/scripts/demo/streamlit_helpers.py#L66
snake_case_           =      0B1011_0011_1110_1100_1001_0000_0111_1011_1011_0001_1001_1110
# bin(x)[2:] gives bits of x as str, use int to convert them to 0/1
snake_case_           =      [int(bit) for bit in bin(WATERMARK_MESSAGE)[2:]]

class 		SCREAMING_SNAKE_CASE__    :


      def __init__(self	:				Optional[Any]				):





         """simple docstring"""



         __snake_case								=       WATERMARK_BITS
         __snake_case								=       WatermarkEncoder()

         self.encoder.set_watermark('''bits'''    ,      self.watermark				)


      def        a			(self	:				List[Any]    ,      a__	:				torch.FloatTensor				):





         """simple docstring"""



         if images.shape[-1] < 256:
            return images

         __snake_case								=       (255 * (images / 2 + 0.5)).cpu().permute(0    ,      2    ,      3    ,      1				).float().numpy()

         __snake_case								=       [self.encoder.encode(__A    ,      '''dwtDct'''				) for image in images]

         __snake_case								=       torch.from_numpy(np.array(__A				)				).permute(0    ,      3    ,      1    ,      2				)

         __snake_case								=       torch.clamp(2 * (images / 255 - 0.5)    ,      min=-1.0    ,      max=1.0				)
         return images








# Copyright 2023 The HuggingFace Team. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from typing import TYPE_CHECKING

# rely on isort to merge the imports
from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available, is_vision_available


snake_case_           =      {
    'configuration_vivit': ['VIVIT_PRETRAINED_CONFIG_ARCHIVE_MAP', 'VivitConfig'],
}
try:
    if not is_vision_available():
        raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
    pass
else:
    snake_case_           =      ['VivitImageProcessor']


try:
    if not is_torch_available():
        raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
    pass
else:
    snake_case_           =      [
        'VIVIT_PRETRAINED_MODEL_ARCHIVE_LIST',
        'VivitModel',
        'VivitPreTrainedModel',
        'VivitForVideoClassification',
    ]


if TYPE_CHECKING:
    from .configuration_vivit import VIVIT_PRETRAINED_CONFIG_ARCHIVE_MAP, VivitConfig

    try:
        if not is_vision_available():
            raise OptionalDependencyNotAvailable()
    except OptionalDependencyNotAvailable:
        pass
    else:
        from .image_processing_vivit import VivitImageProcessor

    try:
        if not is_torch_available():
            raise OptionalDependencyNotAvailable()
    except OptionalDependencyNotAvailable:
        pass
    else:
        from .modeling_vivit import (
            VIVIT_PRETRAINED_MODEL_ARCHIVE_LIST,
            VivitForVideoClassification,
            VivitModel,
            VivitPreTrainedModel,
        )


else:
    import sys

    snake_case_           =      _LazyModule(__name__, globals()['__file__'], _import_structure, module_spec=__spec__)

