

from dataclasses import dataclass
from typing import Optional, Tuple

import torch
from torch import nn
from transformers import RobertaPreTrainedModel, XLMRobertaConfig, XLMRobertaModel
from transformers.utils import ModelOutput





@dataclass
class 				__lowerCAmelCase  (      SCREAMING_SNAKE_CASE							):
  _a		    =						None
  _a		    =						None
  _a		    =						None
  _a		    =						None





class 				__lowerCAmelCase  (      SCREAMING_SNAKE_CASE							):




  def __init__(       self							,     lowerCAmelCase=1							,     lowerCAmelCase=0							,     lowerCAmelCase=2							,     lowerCAmelCase=512							,     lowerCAmelCase="cls"							,     lowerCAmelCase=False							,     lowerCAmelCase=True							,     **lowerCAmelCase							,     )						->				List[Any]:
        '''simple docstring'''






        super().__init__(pad_token_id=lowerCAmelCase							,     bos_token_id=lowerCAmelCase							,     eos_token_id=lowerCAmelCase							,     **lowerCAmelCase      )
        _lowercase			 =project_dim
        _lowercase			 =pooler_fn
        _lowercase			 =learn_encoder
        _lowercase			 =use_attention_mask





class 				__lowerCAmelCase  (      SCREAMING_SNAKE_CASE							):
  _a		    =						[R"""pooler""", R"""logit_scale"""]
  _a		    =						[R"""position_ids""", R"""predictions.decoder.bias"""]
  _a		    =						"""roberta"""
  _a		    =						RobertaSeriesConfig




  def __init__(       self							,     lowerCAmelCase      )						->				Tuple:
        '''simple docstring'''






        super().__init__(lowerCAmelCase      )
        _lowercase			 =XLMRobertaModel(lowerCAmelCase      )
        _lowercase			 =nn.Linear(config.hidden_size							,     config.project_dim      )
        _lowercase			 =getattr(lowerCAmelCase							,     'has_pre_transformation'							,     lowerCAmelCase      )
        if self.has_pre_transformation:
              _lowercase			 =nn.Linear(config.hidden_size							,     config.project_dim      )
              _lowercase			 =nn.LayerNorm(config.hidden_size							,     eps=config.layer_norm_eps      )
        self.post_init()




  def 						A__  (       self							,     lowerCAmelCase = None							,     lowerCAmelCase = None							,     lowerCAmelCase = None							,     lowerCAmelCase = None							,     lowerCAmelCase = None							,     lowerCAmelCase = None							,     lowerCAmelCase = None							,     lowerCAmelCase = None							,     lowerCAmelCase = None							,     lowerCAmelCase = None							,     lowerCAmelCase = None							,     )						->				Any:
        '''simple docstring'''






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

        _lowercase			 =self.base_model(
            input_ids=lowerCAmelCase							,     attention_mask=lowerCAmelCase							,     token_type_ids=lowerCAmelCase							,     position_ids=lowerCAmelCase							,     head_mask=lowerCAmelCase							,     inputs_embeds=lowerCAmelCase							,     encoder_hidden_states=lowerCAmelCase							,     encoder_attention_mask=lowerCAmelCase							,     output_attentions=lowerCAmelCase							,     output_hidden_states=True if self.has_pre_transformation else output_hidden_states							,     return_dict=lowerCAmelCase							,     )

        if self.has_pre_transformation:
              _lowercase			 =outputs['hidden_states'][-2]
              _lowercase			 =self.pre_LN(lowerCAmelCase      )
              _lowercase			 =self.transformation_pre(lowerCAmelCase      )

              return TransformationModelOutput(
                  projection_state=lowerCAmelCase							,     last_hidden_state=outputs.last_hidden_state							,     hidden_states=outputs.hidden_states							,     attentions=outputs.attentions							,     )
        else:
              _lowercase			 =self.transformation(outputs.last_hidden_state      )
              return TransformationModelOutput(
                  projection_state=lowerCAmelCase							,     last_hidden_state=outputs.last_hidden_state							,     hidden_states=outputs.hidden_states							,     attentions=outputs.attentions							,     )





import requests

lowercase_             =     'YOUR API KEY'
def   a   (    A__			:     str   ,     A__			:     str = giphy_api_key  )					->   list:





      """simple docstring"""



      _lowercase			 ='+'.join(query.split()  )
      _lowercase			 =F'''https://api.giphy.com/v1/gifs/search?q={formatted_query}&api_key={api_key}'''
      _lowercase			 =requests.get(A__  ).json()['data']
      return [gif["url"] for gif in gifs]


if __name__ == "__main__":
  print('\n'.join(get_gifs('space ship')))


