<jupyter_start><jupyter_text>InstructionsBuild a head localization deep learning model in PyTorch.Your model takes as an input X tensor and outputs predictions over 4 coordinates for 2 points that define a bounding box.Read more about pytorch and model definition in the following resources:https://towardsdatascience.com/pytorch-tutorial-distilled-95ce8781a89c?gi=ef974c787a5ehttp://pytorch.org/tutorials/beginner/deep_learning_60min_blitz.htmlNow the architecture that you need is the following:Remember your model has 4 outputs as we do classification rather than regression as explained here:https://blog.deepsense.ai/deep-learning-right-whale-recognition-kaggle/  Your SolutionYour solution function should be called solution. CONFIG is a dictionary with all parameters that you want to pass to your solution function<jupyter_code>import torch.nn as nn
CONFIG = {'input_size':(3, 256, 256),
         'classes':128}

def solution(input_shape, classes):
    class PyTorchLocalizer(nn.Module):
        def __init__(self, input_shape, classes):
            """
            input_shape: tuple representing shape
            classes: int, number of localization bins
            """
            super(PyTorchLocalizer, self).__init__()
            
            self.features = nn.Sequential(

                #Feature extraction part of the neural network.
                #Stack those layers to get architecture defined in the notes above.

            )
            self.flat_features_nr = self._get_flat_features_nr(input_shape, self.features)

            self.point1_x = nn.Sequential(
                
                #Put your classification layers for point1_x  
            )

            self.point1_y = nn.Sequential(
                
                #Put your classification layers for point1_y
            )

            self.point2_x = nn.Sequential(

                #Put your classification layers for point2_x

            )

            self.point2_y = nn.Sequential(
                
                #Put your classification layers for point2_y
            )

        def _get_flat_features_nr(self, in_size, features):
            """
            Linear layers need to know what is the size of the input.
            Implement a function that 
            """
            return flattened_features_size

        def forward(self, x):
            """
            Implement forward pass through the network
            """
            return [pred_p1x, pred_p1y, pred_p2x, pred_p2y]

        def forward_target(self, x):
            """
            Sometimes output from the forward pass will contain auxilary target
            In that case you might want to have a separate forward pass for just 
            your target. 
            """
            return self.forward(x)
    
    return PyTorchLocalizer(input_shape, classes)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.06013208202989225, 'fraction_numerical': 0.014598540145985401, 'mean_word_length': 2.148796498905908, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '359728', 'license': 'MIT', 'n_tokens_mistral': 766, 'n_tokens_neox': 719, 'n_words': 241, 'path': 'resources/whales/tasks/task1.ipynb', 'repo_name': 'pknut/minerva', 'size': '2877'}