


_A		       =						{'a': ['c', 'b'], 'b': ['d', 'e'], 'c': [], 'd': [], 'e': []}
_A		       =						['a', 'b', 'c', 'd', 'e']

def 						_UpperCAmelCase				(			SCREAMING_SNAKE_CASE__			:					Tuple			,     SCREAMING_SNAKE_CASE__			:					List[Any]			,     SCREAMING_SNAKE_CASE__			:					str				):
     __UpperCamelCase    							=start
     # add current to visited
     visited.append(SCREAMING_SNAKE_CASE__				)
     __UpperCamelCase    							=edges[current]
     for neighbor in neighbors:
          # if neighbor not in visited, visit
          if neighbor not in visited:
               __UpperCamelCase    							=topological_sort(SCREAMING_SNAKE_CASE__			,     SCREAMING_SNAKE_CASE__			,     SCREAMING_SNAKE_CASE__				)
    # if all neighbors visited add current to sort
     sort.append(SCREAMING_SNAKE_CASE__				)
     # if all vertices haven't been visited select a new one to visit
     if len(SCREAMING_SNAKE_CASE__				) != len(SCREAMING_SNAKE_CASE__				):
          for vertice in vertices:
               if vertice not in visited:
                    __UpperCamelCase    							=topological_sort(SCREAMING_SNAKE_CASE__			,     SCREAMING_SNAKE_CASE__			,     SCREAMING_SNAKE_CASE__				)
    # return sort
     return sort


if __name__ == "__main__":
   _A		       =						topological_sort('a', [], [])
   print(sort)












import torch
from transformers import PreTrainedModel, XLMRobertaConfig, XLMRobertaModel

class    lowerCAmelCase							(					__UpperCamelCase			):
 UpperCAmelCase__													=		"""M-CLIP"""
 def __init__(      self  :      Optional[Any]			,     UpperCAmelCase  :      Union[str, Any]=1024			,     UpperCAmelCase  :      Tuple=768			,     **UpperCAmelCase  :      Optional[int]	)			->	Dict:
     lowerCamelCase__    :      Optional[int]					 =		transformerDimSize
     lowerCamelCase__    :      Optional[Any]					 =		imageDimSize
     super().__init__(**UpperCAmelCase	)


class    lowerCAmelCase							(					__UpperCamelCase			):
 UpperCAmelCase__													=		MCLIPConfig
 def __init__(      self  :      List[Any]			,     UpperCAmelCase  :      Dict			,     *UpperCAmelCase  :      Any			,     **UpperCAmelCase  :      Dict	)			->	Dict:
     super().__init__(UpperCAmelCase			,     *UpperCAmelCase			,     **UpperCAmelCase	)
     lowerCamelCase__    :      Tuple					 =		XLMRobertaModel(UpperCAmelCase	)
     lowerCamelCase__    :      Union[str, Any]					 =		torch.nn.Linear(
         in_features=config.transformerDimensions			,     out_features=config.numDims	)







 def      A_	(      self  :      Optional[int]			,     UpperCAmelCase  :      Optional[Any]			,     UpperCAmelCase  :      Dict	)			->	Tuple:
     lowerCamelCase__    :      Any					 =		self.transformer(input_ids=UpperCAmelCase			,     attention_mask=UpperCAmelCase	)[0]
     lowerCamelCase__    :      int					 =		(embs * attention_mask.unsqueeze(2	)).sum(dim=1	) / attention_mask.sum(dim=1	)[:, None]
     return self.LinearTransformation(UpperCAmelCase	), embs





