






'''simple docstring'''
import tensorflow as tf

from ...tf_utils import shape_list


class        _UpperCAmelCase						(		tf.keras.layers.Layer			):




    def __init__(			self  :       Optional[int]  ,     a  :       List[str]  ,     a  :       Any  ,     a  :       int  ,     a  :       List[Any]  ,     a  :       List[str]=1  ,     a  :       Optional[int]=False  ,     **a  :       Tuple			):






       '''simple docstring'''






       super().__init__(**a			)

       lowercase_	:    Tuple           =     vocab_size
       lowercase_	:    Union[str, Any]           =     d_embed
       lowercase_	:    Dict           =     d_proj

       lowercase_	:    Any           =     cutoffs + [vocab_size]
       lowercase_	:    Optional[int]           =     [0] + self.cutoffs
       lowercase_	:    List[str]           =     div_val

       lowercase_	:    Any           =     self.cutoffs[0]
       lowercase_	:    int           =     len(self.cutoffs			) - 1
       lowercase_	:    Any           =     self.shortlist_size + self.n_clusters
       lowercase_	:    Union[str, Any]           =     keep_order

       lowercase_	:    List[str]           =     []
       lowercase_	:    Optional[Any]           =     []




    def 				lowerCAmelCase__				(			self  :       str  ,     a  :       Optional[Any]			):






       '''simple docstring'''






       if self.n_clusters > 0:
          lowercase_	:    Optional[Any]           =     self.add_weight(
              shape=(self.n_clusters, self.d_embed)  ,     initializer="zeros"  ,     trainable=a  ,     name="cluster_weight"			)
          lowercase_	:    int           =     self.add_weight(
              shape=(self.n_clusters,)  ,     initializer="zeros"  ,     trainable=a  ,     name="cluster_bias"			)

       if self.div_val == 1:
          for i in range(len(self.cutoffs			)			):
             if self.d_proj != self.d_embed:
                lowercase_	:    str           =     self.add_weight(
                    shape=(self.d_embed, self.d_proj)  ,     initializer="zeros"  ,     trainable=a  ,     name=f"""out_projs_._{i}"""  ,     )
                self.out_projs.append(a			)
             else:
                self.out_projs.append(a			)
             lowercase_	:    Dict           =     self.add_weight(
                 shape=(self.vocab_size, self.d_embed)  ,     initializer="zeros"  ,     trainable=a  ,     name=f"""out_layers_._{i}_._weight"""  ,     )
             lowercase_	:    str           =     self.add_weight(
                 shape=(self.vocab_size,)  ,     initializer="zeros"  ,     trainable=a  ,     name=f"""out_layers_._{i}_._bias"""  ,     )
             self.out_layers.append((weight, bias)			)
       else:
          for i in range(len(self.cutoffs			)			):
             lowercase_    ,		lowercase_	:    Union[str, Any]           =     self.cutoff_ends[i], self.cutoff_ends[i + 1]
             lowercase_	:    Optional[int]           =     self.d_embed // (self.div_val**i)

             lowercase_	:    Union[str, Any]           =     self.add_weight(
                 shape=(d_emb_i, self.d_proj)  ,     initializer="zeros"  ,     trainable=a  ,     name=f"""out_projs_._{i}"""			)
             self.out_projs.append(a			)
             lowercase_	:    List[Any]           =     self.add_weight(
                 shape=(r_idx - l_idx, d_emb_i)  ,     initializer="zeros"  ,     trainable=a  ,     name=f"""out_layers_._{i}_._weight"""  ,     )
             lowercase_	:    str           =     self.add_weight(
                 shape=(r_idx - l_idx,)  ,     initializer="zeros"  ,     trainable=a  ,     name=f"""out_layers_._{i}_._bias"""  ,     )
             self.out_layers.append((weight, bias)			)
       super().build(a			)




    @staticmethod
    def 				lowerCAmelCase__				(			a  :       Union[str, Any]  ,     a  :       Optional[Any]  ,     a  :       Any  ,     a  :       Tuple=None			):






       '''simple docstring'''






       lowercase_	:    List[Any]           =     x
       if proj is not None:
          lowercase_	:    int           =     tf.einsum("ibd,ed->ibe"  ,     a  ,     a			)
       return tf.einsum("ibd,nd->ibn"  ,     a  ,     a			) + b




    @staticmethod
    def 				lowerCAmelCase__				(			a  :       Optional[Any]  ,     a  :       Union[str, Any]			):






       '''simple docstring'''






       lowercase_	:    Union[str, Any]           =     shape_list(a			)
       lowercase_	:    int           =     tf.range(lp_size[0]  ,     dtype=target.dtype			)
       lowercase_	:    int           =     tf.stack([r, target]  ,     1			)
       return tf.gather_nd(a  ,     a			)





    def 				lowerCAmelCase__				(			self  :       Tuple  ,     a  :       List[str]  ,     a  :       Any  ,     a  :       List[Any]=True  ,     a  :       Dict=False			):






       '''simple docstring'''






       lowercase_	:    Optional[Any]           =     0
       if self.n_clusters == 0:
          lowercase_	:    List[Any]           =     self._logit(a  ,     self.out_layers[0][0]  ,     self.out_layers[0][1]  ,     self.out_projs[0]			)
          if target is not None:
             lowercase_	:    Union[str, Any]           =     tf.nn.sparse_softmax_cross_entropy_with_logits(labels=a  ,     logits=a			)
          lowercase_	:    Tuple           =     tf.nn.log_softmax(a  ,     axis=-1			)
       else:
          lowercase_	:    Optional[int]           =     shape_list(a			)
          lowercase_	:    Optional[int]           =     []
          lowercase_	:    Union[str, Any]           =     tf.zeros(hidden_sizes[:2]			)
          for i in range(len(self.cutoffs			)			):
             lowercase_    ,		lowercase_	:    Union[str, Any]           =     self.cutoff_ends[i], self.cutoff_ends[i + 1]
             if target is not None:
                lowercase_	:    Optional[Any]           =     (target >= l_idx) & (target < r_idx)
                lowercase_	:    Optional[int]           =     tf.where(a			)
                lowercase_	:    Dict           =     tf.boolean_mask(a  ,     a			) - l_idx

             if self.div_val == 1:
                lowercase_	:    Optional[int]           =     self.out_layers[0][0][l_idx:r_idx]
                lowercase_	:    Optional[int]           =     self.out_layers[0][1][l_idx:r_idx]
             else:
                lowercase_	:    Tuple           =     self.out_layers[i][0]
                lowercase_	:    str           =     self.out_layers[i][1]

             if i == 0:
                lowercase_	:    int           =     tf.concat([cur_W, self.cluster_weight]  ,     0			)
                lowercase_	:    Any           =     tf.concat([cur_b, self.cluster_bias]  ,     0			)

                lowercase_	:    Optional[int]           =     self._logit(a  ,     a  ,     a  ,     self.out_projs[0]			)
                lowercase_	:    str           =     tf.nn.log_softmax(a			)
                out.append(head_logprob[..., : self.cutoffs[0]]			)
                if target is not None:
                   lowercase_	:    Optional[int]           =     tf.boolean_mask(a  ,     a			)
                   lowercase_	:    int           =     self._gather_logprob(a  ,     a			)
             else:
                lowercase_	:    Tuple           =     self._logit(a  ,     a  ,     a  ,     self.out_projs[i]			)
                lowercase_	:    str           =     tf.nn.log_softmax(a			)
                lowercase_	:    int           =     self.cutoffs[0] + i - 1  # No probability for the head cluster
                lowercase_	:    List[str]           =     head_logprob[..., cluster_prob_idx, None] + tail_logprob
                out.append(a			)
                if target is not None:
                   lowercase_	:    Any           =     tf.boolean_mask(a  ,     a			)
                   lowercase_	:    Optional[Any]           =     tf.boolean_mask(a  ,     a			)
                   lowercase_	:    str           =     self._gather_logprob(a  ,     a			)
                   cur_logprob += cur_head_logprob[:, self.cutoff_ends[1] + i - 1]
             if target is not None:
                loss += tf.scatter_nd(a  ,     -cur_logprob  ,     shape_list(a			)			)
          lowercase_	:    str           =     tf.concat(a  ,     axis=-1			)

       if target is not None:
          if return_mean:
             lowercase_	:    Optional[int]           =     tf.reduce_mean(a			)
          # Add the training-time loss value to the layer using `self.add_loss()`.
          self.add_loss(a			)

          # Log the loss as a metric (we could log arbitrary metrics,
          # including different metrics for training and inference.
          self.add_metric(a  ,     name=self.name  ,     aggregation="mean" if return_mean else ""			)

       return out












'''simple docstring'''
def 		__SCREAMING_SNAKE_CASE					(  _UpperCamelCase							):


   """simple docstring"""




   lowercase_	:    Any           =     False
   while is_sorted is False:  # Until all the indices are traversed keep looping
      lowercase_	:    List[str]           =     True
      for i in range(0						,		len(_UpperCamelCase							) - 1						,		2							):  # iterating over all even indices
         if input_list[i] > input_list[i + 1]:
            lowercase_    ,		lowercase_	:    Union[str, Any]           =     input_list[i + 1], input_list[i]
            # swapping if elements not in order
            lowercase_	:    Any           =     False

      for i in range(1						,		len(_UpperCamelCase							) - 1						,		2							):  # iterating over all odd indices
         if input_list[i] > input_list[i + 1]:
            lowercase_    ,		lowercase_	:    Tuple           =     input_list[i + 1], input_list[i]
            # swapping if elements not in order
            lowercase_	:    List[Any]           =     False
   return input_list


if __name__ == "__main__":
 print('Enter list to be sorted')
 UpperCamelCase__ =			[int(x) for x in input().split()]
 # inputing elements of the list in one line
 UpperCamelCase__ =			odd_even_sort(input_list)
 print('The sorted list is')
 print(sorted_list)




