



import math
from typing import Callable, List, Optional, Union

import numpy as np
import PIL
import torch
from PIL import Image
from transformers import CLIPTextModel, CLIPTokenizer

from diffusers.models import AutoencoderKL, UNetaDConditionModel
from diffusers.pipelines.stable_diffusion.pipeline_stable_diffusion_upscale import StableDiffusionUpscalePipeline
from diffusers.schedulers import DDIMScheduler, DDPMScheduler, LMSDiscreteScheduler, PNDMScheduler

def      __lowercase(						UpperCAmelCase__ , UpperCAmelCase__ , UpperCAmelCase__=[]			):


      """simple docstring"""



      lowerCamelCase             =		size[0] - overlap_pixels * 2
      lowerCamelCase             =		size[1] - overlap_pixels * 2
      for letter in ["l", "r"]:
            if letter in remove_borders:
                  size_x += overlap_pixels
      for letter in ["t", "b"]:
            if letter in remove_borders:
                  size_y += overlap_pixels
      lowerCamelCase             =		np.ones((size_y, size_x) , dtype=np.uinta			) * 255
      lowerCamelCase             =		np.pad(UpperCAmelCase__ , mode="linear_ramp" , pad_width=UpperCAmelCase__ , end_values=0			)

      if "l" in remove_borders:
            lowerCamelCase             =		mask[:, overlap_pixels : mask.shape[1]]
      if "r" in remove_borders:
            lowerCamelCase             =		mask[:, 0 : mask.shape[1] - overlap_pixels]
      if "t" in remove_borders:
            lowerCamelCase             =		mask[overlap_pixels : mask.shape[0], :]
      if "b" in remove_borders:
            lowerCamelCase             =		mask[0 : mask.shape[0] - overlap_pixels, :]
      return mask

def      __lowercase(						UpperCAmelCase__ , UpperCAmelCase__ , UpperCAmelCase__			):


      """simple docstring"""



      return max(UpperCAmelCase__ , min(UpperCAmelCase__ , UpperCAmelCase__			)			)

def      __lowercase(						UpperCAmelCase__ , UpperCAmelCase__ , UpperCAmelCase__			):


      """simple docstring"""



      return (
          clamp(rect[0] , min[0] , max[0]			),
          clamp(rect[1] , min[1] , max[1]			),
          clamp(rect[2] , min[0] , max[0]			),
          clamp(rect[3] , min[1] , max[1]			),
      )

def      __lowercase(						UpperCAmelCase__ , UpperCAmelCase__ , UpperCAmelCase__			):


      """simple docstring"""



      lowerCamelCase             =		list(UpperCAmelCase__			)
      rect[0] -= overlap
      rect[1] -= overlap
      rect[2] += overlap
      rect[3] += overlap
      lowerCamelCase             =		clamp_rect(UpperCAmelCase__ , [0, 0] , [image_size[0], image_size[1]]			)
      return rect

def      __lowercase(						UpperCAmelCase__ , UpperCAmelCase__ , UpperCAmelCase__ , UpperCAmelCase__			):


      """simple docstring"""



      lowerCamelCase             =		Image.new("RGB" , (tile.size[0] + original_slice, tile.size[1])			)
      result.paste(
          original_image.resize((tile.size[0], tile.size[1]) , Image.BICUBIC			).crop(
              (slice_x, 0, slice_x + original_slice, tile.size[1])			) , (0, 0) , )
      result.paste(UpperCAmelCase__ , (original_slice, 0)			)
      return result

def      __lowercase(						UpperCAmelCase__ , UpperCAmelCase__			):


      """simple docstring"""



      lowerCamelCase             =		(original_image_slice * 4, 0, tile.size[0], tile.size[1])
      lowerCamelCase             =		tile.crop(UpperCAmelCase__			)
      return tile

def      __lowercase(						UpperCAmelCase__ , UpperCAmelCase__			):


      """simple docstring"""



      lowerCamelCase             =		n % d
      return n - divisor





class  lowerCamelCase__	(    UpperCAmelCase_):
     """simple docstring"""



     def __init__(self					,      __a					,      __a					,      __a					,      __a					,      __a					,      __a					,      __a = 3_50					,      ):






           '''simple docstring'''



           super().__init__(
               vae=__a					,      text_encoder=__a					,      tokenizer=__a					,      unet=__a					,      low_res_scheduler=__a					,      scheduler=__a					,      max_noise_level=__a					,      )







     def     _a   (self					,      __a					,      __a					,      __a					,      __a					,      __a					,      __a					,      __a					,      **__a     ):






           '''simple docstring'''



           torch.manual_seed(0     )
           lowerCamelCase             =		(
               min(image.size[0] - (tile_size + original_image_slice)					,      x * tile_size     ),
               min(image.size[1] - (tile_size + original_image_slice)					,      y * tile_size     ),
               min(image.size[0]					,      (x + 1) * tile_size     ),
               min(image.size[1]					,      (y + 1) * tile_size     ),
           )
           lowerCamelCase             =		add_overlap_rect(__a					,      __a					,      image.size     )
           lowerCamelCase             =		image.crop(__a     )
           lowerCamelCase             =		((crop_rect[0] + ((crop_rect[2] - crop_rect[0]) / 2)) / image.size[0]) * tile.size[0]
           lowerCamelCase             =		translated_slice_x - (original_image_slice / 2)
           lowerCamelCase             =		max(0					,      __a     )
           lowerCamelCase             =		squeeze_tile(__a					,      __a					,      __a					,      __a     )
           lowerCamelCase             =		to_input.size
           lowerCamelCase             =		to_input.resize((tile_size, tile_size)					,      Image.BICUBIC     )
           lowerCamelCase             =		super(__a					,      self     ).__call__(image=__a					,      **__a     ).images[0]
           lowerCamelCase             =		upscaled_tile.resize((orig_input_size[0] * 4, orig_input_size[1] * 4)					,      Image.BICUBIC     )
           lowerCamelCase             =		unsqueeze_tile(__a					,      __a     )
           lowerCamelCase             =		upscaled_tile.resize((tile.size[0] * 4, tile.size[1] * 4)					,      Image.BICUBIC     )
           lowerCamelCase             =		[]
           if x == 0:
                 remove_borders.append("l"     )
           elif crop_rect[2] == image.size[0]:
                 remove_borders.append("r"     )
           if y == 0:
                 remove_borders.append("t"     )
           elif crop_rect[3] == image.size[1]:
                 remove_borders.append("b"     )
           lowerCamelCase             =		Image.fromarray(
               make_transparency_mask(
                   (upscaled_tile.size[0], upscaled_tile.size[1])					,      tile_border * 4					,      remove_borders=__a     )					,      mode="L"					,      )
           final_image.paste(
               __a					,      (crop_rect_with_overlap[0] * 4, crop_rect_with_overlap[1] * 4)					,      __a     )







     @torch.no_grad()
     def __call__(self					,      __a					,      __a					,      __a = 75					,      __a = 9.0					,      __a = 50					,      __a = None					,      __a = 1					,      __a = 0.0					,      __a = None					,      __a = None					,      __a = None					,      __a = 1					,      __a = 1_28					,      __a = 32					,      __a = 32					,      ):






           '''simple docstring'''



           lowerCamelCase             =		Image.new("RGB"					,      (image.size[0] * 4, image.size[1] * 4)     )
           lowerCamelCase             =		math.ceil(image.size[0] / tile_size     )
           lowerCamelCase             =		math.ceil(image.size[1] / tile_size     )
           lowerCamelCase             =		tcx * tcy
           lowerCamelCase             =		0
           for y in range(__a     ):
                 for x in range(__a     ):
                       self._process_tile(
                           __a					,      __a					,      __a					,      __a					,      __a					,      __a					,      __a					,      prompt=__a					,      num_inference_steps=__a					,      guidance_scale=__a					,      noise_level=__a					,      negative_prompt=__a					,      num_images_per_prompt=__a					,      eta=__a					,      generator=__a					,      latents=__a					,      )
                       current_count += 1
                       if callback is not None:
                             callback({"progress": current_count / total_tile_count, "image": final_image}     )
           return final_image



def      __lowercase(						):


      """simple docstring"""



      lowerCamelCase             =		"stabilityai/stable-diffusion-x4-upscaler"
      lowerCamelCase             =		StableDiffusionTiledUpscalePipeline.from_pretrained(UpperCAmelCase__ , revision="fp16" , torch_dtype=torch.floataa			)
      lowerCamelCase             =		pipe.to("cuda"			)
      lowerCamelCase             =		Image.open("../../docs/source/imgs/diffusers_library.jpg"			)

      def callback(UpperCAmelCase__			):
            print(F"""progress: {obj["progress"]:.4f}"""			)
            obj["image"].save("diffusers_library_progress.jpg"			)

      lowerCamelCase             =		pipe(image=UpperCAmelCase__ , prompt="Black font, white background, vector" , noise_level=40 , callback=UpperCAmelCase__			)
      final_image.save("diffusers_library.jpg"			)


if __name__ == "__main__":
     main()




from typing import Optional

import torch
import torch.utils.checkpoint
from torch import Tensor, nn
from torch.nn import BCEWithLogitsLoss, CrossEntropyLoss, MSELoss

from ...activations import ACTaFN
from ...file_utils import add_code_sample_docstrings, add_start_docstrings, add_start_docstrings_to_model_forward
from ...modeling_outputs import (
    BaseModelOutputWithNoAttention,
    BaseModelOutputWithPoolingAndNoAttention,
    ImageClassifierOutputWithNoAttention,
)
from ...modeling_utils import PreTrainedModel
from ...utils import logging
from .configuration_regnet import RegNetConfig


a_    :  Optional[int]						  =		logging.get_logger(__name__)

# General docstring
a_    :  List[str]						  =		'RegNetConfig'

# Base docstring
a_    :  Union[str, Any]						  =		'facebook/regnet-y-040'
a_    :  Optional[Any]						  =		[1, 1_0_8_8, 7, 7]

# Image classification docstring
a_    :  Dict						  =		'facebook/regnet-y-040'
a_    :  List[Any]						  =		'tabby, tabby cat'

a_    :  Union[str, Any]						  =		[
    'facebook/regnet-y-040',
    # See all regnet models at https://huggingface.co/models?filter=regnet
]





class  lowerCamelCase__	(    nn.Module):
     """simple docstring"""



     def __init__(self					,      __a					,      __a					,      __a = 3					,      __a = 1					,      __a = 1					,      __a = "relu"					,      ):






           '''simple docstring'''



           super().__init__()
           lowerCamelCase             =		nn.Convad(
               __a					,      __a					,      kernel_size=__a					,      stride=__a					,      padding=kernel_size // 2					,      groups=__a					,      bias=__a					,      )
           lowerCamelCase             =		nn.BatchNormad(__a     )
           lowerCamelCase             =		ACTaFN[activation] if activation is not None else nn.Identity()







     def     _a   (self					,      __a     ):






           '''simple docstring'''



           lowerCamelCase             =		self.convolution(__a     )
           lowerCamelCase             =		self.normalization(__a     )
           lowerCamelCase             =		self.activation(__a     )
           return hidden_state





class  lowerCamelCase__	(    nn.Module):
     """simple docstring"""



     def __init__(self					,      __a     ):






           '''simple docstring'''



           super().__init__()
           lowerCamelCase             =		RegNetConvLayer(
               config.num_channels					,      config.embedding_size					,      kernel_size=3					,      stride=2					,      activation=config.hidden_act     )
           lowerCamelCase             =		config.num_channels







     def     _a   (self					,      __a     ):






           '''simple docstring'''



           lowerCamelCase             =		pixel_values.shape[1]
           if num_channels != self.num_channels:
                 raise ValueError(
                     "Make sure that the channel dimension of the pixel values match with the one set in the configuration."     )
           lowerCamelCase             =		self.embedder(__a     )
           return hidden_state





class  lowerCamelCase__	(    nn.Module):
     """simple docstring"""



     def __init__(self					,      __a					,      __a					,      __a = 2     ):






           '''simple docstring'''



           super().__init__()
           lowerCamelCase             =		nn.Convad(__a					,      __a					,      kernel_size=1					,      stride=__a					,      bias=__a     )
           lowerCamelCase             =		nn.BatchNormad(__a     )







     def     _a   (self					,      __a     ):






           '''simple docstring'''



           lowerCamelCase             =		self.convolution(__a     )
           lowerCamelCase             =		self.normalization(__a     )
           return hidden_state





class  lowerCamelCase__	(    nn.Module):
     """simple docstring"""



     def __init__(self					,      __a					,      __a     ):






           '''simple docstring'''



           super().__init__()

           lowerCamelCase             =		nn.AdaptiveAvgPoolad((1, 1)     )
           lowerCamelCase             =		nn.Sequential(
               nn.Convad(__a					,      __a					,      kernel_size=1     )					,      nn.ReLU()					,      nn.Convad(__a					,      __a					,      kernel_size=1     )					,      nn.Sigmoid()					,      )







     def     _a   (self					,      __a     ):






           '''simple docstring'''



           lowerCamelCase             =		self.pooler(__a     )
           lowerCamelCase             =		self.attention(__a     )
           lowerCamelCase             =		hidden_state * attention
           return hidden_state





class  lowerCamelCase__	(    nn.Module):
     """simple docstring"""



     def __init__(self					,      __a					,      __a					,      __a					,      __a = 1     ):






           '''simple docstring'''



           super().__init__()
           lowerCamelCase             =		in_channels != out_channels or stride != 1
           lowerCamelCase             =		max(1					,      out_channels // config.groups_width     )
           lowerCamelCase             =		(
               RegNetShortCut(__a					,      __a					,      stride=__a     ) if should_apply_shortcut else nn.Identity()
           )
           lowerCamelCase             =		nn.Sequential(
               RegNetConvLayer(__a					,      __a					,      kernel_size=1					,      activation=config.hidden_act     )					,      RegNetConvLayer(__a					,      __a					,      stride=__a					,      groups=__a					,      activation=config.hidden_act     )					,      RegNetConvLayer(__a					,      __a					,      kernel_size=1					,      activation=__a     )					,      )
           lowerCamelCase             =		ACTaFN[config.hidden_act]







     def     _a   (self					,      __a     ):






           '''simple docstring'''



           lowerCamelCase             =		hidden_state
           lowerCamelCase             =		self.layer(__a     )
           lowerCamelCase             =		self.shortcut(__a     )
           hidden_state += residual
           lowerCamelCase             =		self.activation(__a     )
           return hidden_state





class  lowerCamelCase__	(    nn.Module):
     """simple docstring"""



     def __init__(self					,      __a					,      __a					,      __a					,      __a = 1     ):






           '''simple docstring'''



           super().__init__()
           lowerCamelCase             =		in_channels != out_channels or stride != 1
           lowerCamelCase             =		max(1					,      out_channels // config.groups_width     )
           lowerCamelCase             =		(
               RegNetShortCut(__a					,      __a					,      stride=__a     ) if should_apply_shortcut else nn.Identity()
           )
           lowerCamelCase             =		nn.Sequential(
               RegNetConvLayer(__a					,      __a					,      kernel_size=1					,      activation=config.hidden_act     )					,      RegNetConvLayer(__a					,      __a					,      stride=__a					,      groups=__a					,      activation=config.hidden_act     )					,      RegNetSELayer(__a					,      reduced_channels=int(round(in_channels / 4     )     )     )					,      RegNetConvLayer(__a					,      __a					,      kernel_size=1					,      activation=__a     )					,      )
           lowerCamelCase             =		ACTaFN[config.hidden_act]







     def     _a   (self					,      __a     ):






           '''simple docstring'''



           lowerCamelCase             =		hidden_state
           lowerCamelCase             =		self.layer(__a     )
           lowerCamelCase             =		self.shortcut(__a     )
           hidden_state += residual
           lowerCamelCase             =		self.activation(__a     )
           return hidden_state





class  lowerCamelCase__	(    nn.Module):
     """simple docstring"""



     def __init__(self					,      __a					,      __a					,      __a					,      __a = 2					,      __a = 2					,      ):






           '''simple docstring'''



           super().__init__()

           lowerCamelCase             =		RegNetXLayer if config.layer_type == "x" else RegNetYLayer

           lowerCamelCase             =		nn.Sequential(
               # downsampling is done in the first layer with stride of 2
               layer(
                   __a					,      __a					,      __a					,      stride=__a					,      )					,      *[layer(__a					,      __a					,      __a     ) for _ in range(depth - 1     )]					,      )







     def     _a   (self					,      __a     ):






           '''simple docstring'''



           lowerCamelCase             =		self.layers(__a     )
           return hidden_state





class  lowerCamelCase__	(    nn.Module):
     """simple docstring"""



     def __init__(self					,      __a     ):






           '''simple docstring'''



           super().__init__()
           lowerCamelCase             =		nn.ModuleList([]     )
           # based on `downsample_in_first_stage`, the first layer of the first stage may or may not downsample the input
           self.stages.append(
               RegNetStage(
                   __a					,      config.embedding_size					,      config.hidden_sizes[0]					,      stride=2 if config.downsample_in_first_stage else 1					,      depth=config.depths[0]					,      )     )
           lowerCamelCase             =		zip(config.hidden_sizes					,      config.hidden_sizes[1:]     )
           for (in_channels, out_channels), depth in zip(__a					,      config.depths[1:]     ):
                 self.stages.append(RegNetStage(__a					,      __a					,      __a					,      depth=__a     )     )







     def     _a   (self					,      __a					,      __a = False					,      __a = True     ):






           '''simple docstring'''



           lowerCamelCase             =		() if output_hidden_states else None

           for stage_module in self.stages:
                 if output_hidden_states:
                       lowerCamelCase             =		hidden_states + (hidden_state,)

                 lowerCamelCase             =		stage_module(__a     )

           if output_hidden_states:
                 lowerCamelCase             =		hidden_states + (hidden_state,)

           if not return_dict:
                 return tuple(v for v in [hidden_state, hidden_states] if v is not None     )

           return BaseModelOutputWithNoAttention(last_hidden_state=__a					,      hidden_states=__a     )





class  lowerCamelCase__	(    UpperCAmelCase_):
     """simple docstring"""



     _A      =      RegNetConfig
     _A      =      'regnet'
     _A      =      'pixel_values'
     _A      =      True







     def     _a   (self					,      __a     ):






           '''simple docstring'''



           if isinstance(__a					,      nn.Convad     ):
                 nn.init.kaiming_normal_(module.weight					,      mode="fan_out"					,      nonlinearity="relu"     )
           elif isinstance(__a					,      (nn.BatchNormad, nn.GroupNorm)     ):
                 nn.init.constant_(module.weight					,      1     )
                 nn.init.constant_(module.bias					,      0     )







     def     _a   (self					,      __a					,      __a=False     ):






           '''simple docstring'''



           if isinstance(__a					,      __a     ):
                 lowerCamelCase             =		value



a_    :  Dict						  =		R'\n    This model is a PyTorch [torch.nn.Module](https://pytorch.org/docs/stable/nn.html#torch.nn.Module) subclass. Use it\n    as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage and\n    behavior.\n\n    Parameters:\n        config ([`RegNetConfig`]): Model configuration class with all the parameters of the model.\n            Initializing with a config file does not load the weights associated with the model, only the\n            configuration. Check out the [`~PreTrainedModel.from_pretrained`] method to load the model weights.\n'

a_    :  Optional[Any]						  =		R'\n    Args:\n        pixel_values (`torch.FloatTensor` of shape `(batch_size, num_channels, height, width)`):\n            Pixel values. Pixel values can be obtained using [`AutoImageProcessor`]. See\n            [`ConvNextImageProcessor.__call__`] for details.\n\n        output_hidden_states (`bool`, *optional*):\n            Whether or not to return the hidden states of all layers. See `hidden_states` under returned tensors for\n            more detail.\n        return_dict (`bool`, *optional*):\n            Whether or not to return a [`~file_utils.ModelOutput`] instead of a plain tuple.\n'





@add_start_docstrings(
    'The bare RegNet model outputting raw features without any specific head on top.'							,     UpperCAmelCase_							,     )
# Copied from transformers.models.resnet.modeling_resnet.ResNetModel with RESNET->REGNET,ResNet->RegNet
class  lowerCamelCase__	(    UpperCAmelCase_):
     """simple docstring"""



     def __init__(self					,      __a     ):






           '''simple docstring'''



           super().__init__(__a     )
           lowerCamelCase             =		config
           lowerCamelCase             =		RegNetEmbeddings(__a     )
           lowerCamelCase             =		RegNetEncoder(__a     )
           lowerCamelCase             =		nn.AdaptiveAvgPoolad((1, 1)     )
           # Initialize weights and apply final processing
           self.post_init()







     @add_start_docstrings_to_model_forward(__a     )
     @add_code_sample_docstrings(
         checkpoint=_CHECKPOINT_FOR_DOC					,      output_type=__a					,      config_class=_CONFIG_FOR_DOC					,      modality="vision"					,      expected_output=_EXPECTED_OUTPUT_SHAPE					,      )
     def     _a   (self					,      __a					,      __a = None					,      __a = None     ):






           '''simple docstring'''



           lowerCamelCase             =		(
               output_hidden_states if output_hidden_states is not None else self.config.output_hidden_states
           )
           lowerCamelCase             =		return_dict if return_dict is not None else self.config.use_return_dict

           lowerCamelCase             =		self.embedder(__a     )

           lowerCamelCase             =		self.encoder(
               __a					,      output_hidden_states=__a					,      return_dict=__a     )

           lowerCamelCase             =		encoder_outputs[0]

           lowerCamelCase             =		self.pooler(__a     )

           if not return_dict:
                 return (last_hidden_state, pooled_output) + encoder_outputs[1:]

           return BaseModelOutputWithPoolingAndNoAttention(
               last_hidden_state=__a					,      pooler_output=__a					,      hidden_states=encoder_outputs.hidden_states					,      )





@add_start_docstrings(
    '\n    RegNet Model with an image classification head on top (a linear layer on top of the pooled features), e.g. for\n    ImageNet.\n    '							,     UpperCAmelCase_							,     )
# Copied from transformers.models.resnet.modeling_resnet.ResNetForImageClassification with RESNET->REGNET,ResNet->RegNet,resnet->regnet
class  lowerCamelCase__	(    UpperCAmelCase_):
     """simple docstring"""



     def __init__(self					,      __a     ):






           '''simple docstring'''



           super().__init__(__a     )
           lowerCamelCase             =		config.num_labels
           lowerCamelCase             =		RegNetModel(__a     )
           # classification head
           lowerCamelCase             =		nn.Sequential(
               nn.Flatten()					,      nn.Linear(config.hidden_sizes[-1]					,      config.num_labels     ) if config.num_labels > 0 else nn.Identity()					,      )
           # initialize weights and apply final processing
           self.post_init()







     @add_start_docstrings_to_model_forward(__a     )
     @add_code_sample_docstrings(
         checkpoint=_IMAGE_CLASS_CHECKPOINT					,      output_type=__a					,      config_class=_CONFIG_FOR_DOC					,      expected_output=_IMAGE_CLASS_EXPECTED_OUTPUT					,      )
     def     _a   (self					,      __a = None					,      __a = None					,      __a = None					,      __a = None					,      ):






           '''simple docstring'''



           lowerCamelCase             =		return_dict if return_dict is not None else self.config.use_return_dict

           lowerCamelCase             =		self.regnet(__a					,      output_hidden_states=__a					,      return_dict=__a     )

           lowerCamelCase             =		outputs.pooler_output if return_dict else outputs[1]

           lowerCamelCase             =		self.classifier(__a     )

           lowerCamelCase             =		None

           if labels is not None:
                 if self.config.problem_type is None:
                       if self.num_labels == 1:
                             lowerCamelCase             =		"regression"
                       elif self.num_labels > 1 and (labels.dtype == torch.long or labels.dtype == torch.int):
                             lowerCamelCase             =		"single_label_classification"
                       else:
                             lowerCamelCase             =		"multi_label_classification"
                 if self.config.problem_type == "regression":
                       lowerCamelCase             =		MSELoss()
                       if self.num_labels == 1:
                             lowerCamelCase             =		loss_fct(logits.squeeze()					,      labels.squeeze()     )
                       else:
                             lowerCamelCase             =		loss_fct(__a					,      __a     )
                 elif self.config.problem_type == "single_label_classification":
                       lowerCamelCase             =		CrossEntropyLoss()
                       lowerCamelCase             =		loss_fct(logits.view(-1					,      self.num_labels     )					,      labels.view(-1     )     )
                 elif self.config.problem_type == "multi_label_classification":
                       lowerCamelCase             =		BCEWithLogitsLoss()
                       lowerCamelCase             =		loss_fct(__a					,      __a     )

           if not return_dict:
                 lowerCamelCase             =		(logits,) + outputs[2:]
                 return (loss,) + output if loss is not None else output

           return ImageClassifierOutputWithNoAttention(loss=__a					,      logits=__a					,      hidden_states=outputs.hidden_states     )