code: import numpy as np
  
  
  def SCREAMING_SNAKE_CASE				(     lowercase_:	List[Any]		,						lowercase_:	List[Any]		,						lowercase_:	List[str]				):
         _UpperCamelCase     :       str  						=  n_draws * class_counts / class_counts.sum()
         # floored means we don't overshoot n_samples, but probably undershoot
         _UpperCamelCase     :       int  						=  np.floor(lowercase_				)
         # we add samples according to how much "left over" probability
         # they had, until we arrive at n_samples
         _UpperCamelCase     :       List[Any]  						=  int(n_draws - floored.sum()				)
         if need_to_add > 0:
                _UpperCamelCase     :       Any  						=  continuous - floored
                _UpperCamelCase     :       Tuple  						=  np.sort(np.unique(lowercase_				)				)[::-1]
                # add according to remainder, but break ties
                # randomly to avoid biases
                for value in values:
                       (_UpperCamelCase      )     :       Union[str, Any]  						=  np.where(remainder == value				)
                       # if we need_to_add less than what's in inds
                       # we draw randomly from them.
                       # if we need to add more, we add them all and
                       # go to the next value
                       _UpperCamelCase     :       List[Any]  						=  min(len(lowercase_				)		,						lowercase_				)
                       _UpperCamelCase     :       Union[str, Any]  						=  rng.choice(lowercase_		,						size=lowercase_		,						replace=lowercase_				)
                       floored[inds] += 1
                       need_to_add -= add_now
                       if need_to_add == 0:
                              break
         return floored.astype(np.intaa				)
  
  
  
  
  
  def SCREAMING_SNAKE_CASE				(     lowercase_:	Dict		,						lowercase_:	List[str]		,						lowercase_:	Any		,						lowercase_:	Dict		,						lowercase_:	Optional[Any]=10				):
         _UpperCamelCase     :       Any  						=  np.unique(lowercase_		,						return_inverse=lowercase_				)
         _UpperCamelCase     :       int  						=  classes.shape[0]
         _UpperCamelCase     :       Optional[Any]  						=  np.bincount(lowercase_				)
         if np.min(lowercase_				) < 2:
                raise ValueError('Minimum class count error'				)
         if n_train < n_classes:
                raise ValueError(
                    'The train_size = %d should be greater or ' 'equal to the number of classes = %d' % (n_train, n_classes)				)
         if n_test < n_classes:
                raise ValueError(
                    'The test_size = %d should be greater or ' 'equal to the number of classes = %d' % (n_test, n_classes)				)
         _UpperCamelCase     :       Union[str, Any]  						=  np.split(np.argsort(lowercase_		,						kind='mergesort'				)		,						np.cumsum(lowercase_				)[:-1]				)
         for _ in range(lowercase_				):
                _UpperCamelCase     :       Dict  						=  approximate_mode(lowercase_		,						lowercase_		,						lowercase_				)
                _UpperCamelCase     :       Any  						=  class_counts - n_i
                _UpperCamelCase     :       Optional[int]  						=  approximate_mode(lowercase_		,						lowercase_		,						lowercase_				)
  
                _UpperCamelCase     :       int  						=  []
                _UpperCamelCase     :       Union[str, Any]  						=  []
  
                for i in range(lowercase_				):
                       _UpperCamelCase     :       List[Any]  						=  rng.permutation(class_counts[i]				)
                       _UpperCamelCase     :       Optional[Any]  						=  class_indices[i].take(lowercase_		,						mode='clip'				)
                       train.extend(perm_indices_class_i[: n_i[i]]				)
                       test.extend(perm_indices_class_i[n_i[i] : n_i[i] + t_i[i]]				)
                _UpperCamelCase     :       Any  						=  rng.permutation(lowercase_				)
                _UpperCamelCase     :       Tuple  						=  rng.permutation(lowercase_				)
  
                yield train, test
  
  
  
  
style_context: from .chunk_utils import chunk_layer
  from .data_transforms import make_atomaa_masks
  from .feats import atomaa_to_atomaa, frames_and_literature_positions_to_atomaa_pos, torsion_angles_to_frames
  from .loss import compute_predicted_aligned_error, compute_tm
  from .protein import Protein as OFProtein
  from .protein import to_pdb
  from .rigid_utils import Rigid, Rotation
  from .tensor_utils import dict_multimap, flatten_final_dims, permute_final_dims
  
  
  
  