





from collections.abc import Callable

import numpy as np






def 							_lowerCAmelCase (  _a   :					Callable					,   _a   :					float					,   _a   :					float					,   _a   :					float					,   _a   :					float			)	->			np.ndarray:
     lowerCAmelCase_					:       str    =		int(np.ceil((x_end - xa) / step_size			)			)
     lowerCAmelCase_					:       List[str]    =		np.zeros((n + 1,)			)
     lowerCAmelCase_					:       Dict    =		ya
     lowerCAmelCase_					:       Tuple    =		xa

     for k in range(_a			):
          lowerCAmelCase_					:       Optional[Any]    =		y[k] + step_size * ode_func(_a					,   y[k]			)
          x += step_size

     return y


if __name__ == "__main__":
      import doctest

      doctest.testmod()







import torch
from transformers import PreTrainedModel, XLMRobertaConfig, XLMRobertaModel





class      lowercase__    (							__A  ):
  __UpperCamelCase	     =  """M-CLIP"""







  def __init__(	self    ,						_lowercase=1_024    ,						_lowercase=768    ,						**_lowercase						):
       lowerCAmelCase_					:       Tuple    =		transformerDimSize
       lowerCAmelCase_					:       Optional[Any]    =		imageDimSize
       super().__init__(**_lowercase						)





class      lowercase__    (							__A  ):
  __UpperCamelCase	     =  MCLIPConfig







  def __init__(	self    ,						_lowercase    ,						*_lowercase    ,						**_lowercase						):
       super().__init__(_lowercase    ,						*_lowercase    ,						**_lowercase						)
       lowerCAmelCase_					:       str    =		XLMRobertaModel(_lowercase						)
       lowerCAmelCase_					:       str    =		torch.nn.Linear(
           in_features=config.transformerDimensions    ,						out_features=config.numDims						)







  def 	UpperCAmelCase__		(	self    ,						_lowercase    ,						_lowercase						):
       lowerCAmelCase_					:       Optional[int]    =		self.transformer(input_ids=_lowercase    ,						attention_mask=_lowercase						)[0]
       lowerCAmelCase_					:       Any    =		(embs * attention_mask.unsqueeze(2						)).sum(dim=1						) / attention_mask.sum(dim=1						)[:, None]
       return self.LinearTransformation(_lowercase						), embs
