




from typing import List, Optional, Tuple, Union

import torch
from torch import nn
from torch.nn import CrossEntropyLoss

from ... import AutoBackbone
from ...modeling_outputs import SemanticSegmenterOutput
from ...modeling_utils import PreTrainedModel
from ...utils import add_start_docstrings, add_start_docstrings_to_model_forward, replace_return_docstrings
from ...utils.backbone_utils import BackboneMixin
from .configuration_upernet import UperNetConfig


__a          =			[
    'openmmlab/upernet-convnext-tiny',
    # See all UperNet models at https://huggingface.co/models?filter=upernet
]

# General docstring
__a          =			'UperNetConfig'

class   __a(					nn.Module       ):






    """simple docstring"""





    def __init__(				self       ,_SCREAMING_SNAKE_CASE       ,_SCREAMING_SNAKE_CASE       ,_SCREAMING_SNAKE_CASE       ,_SCREAMING_SNAKE_CASE = 0       ,_SCREAMING_SNAKE_CASE = False       ,_SCREAMING_SNAKE_CASE = 1       ,)			->		None:
         super().__init__()
         UpperCAmelCase_      :							Optional[int]       =      nn.Convad(
             in_channels=_SCREAMING_SNAKE_CASE       ,out_channels=_SCREAMING_SNAKE_CASE       ,kernel_size=_SCREAMING_SNAKE_CASE       ,padding=_SCREAMING_SNAKE_CASE       ,bias=_SCREAMING_SNAKE_CASE       ,dilation=_SCREAMING_SNAKE_CASE       ,)
         UpperCAmelCase_      :							Union[str, Any]       =      nn.BatchNormad(_SCREAMING_SNAKE_CASE  )
         UpperCAmelCase_      :							List[Any]       =      nn.ReLU()





    def 							a__				(				self       ,_SCREAMING_SNAKE_CASE  )			->		torch.Tensor:
         UpperCAmelCase_      :							str       =      self.conv(_SCREAMING_SNAKE_CASE  )
         UpperCAmelCase_      :							List[str]       =      self.batch_norm(_SCREAMING_SNAKE_CASE  )
         UpperCAmelCase_      :							int       =      self.activation(_SCREAMING_SNAKE_CASE  )

         return output


class   __a(					nn.Module       ):






    """simple docstring"""





    def __init__(				self       ,_SCREAMING_SNAKE_CASE       ,_SCREAMING_SNAKE_CASE       ,_SCREAMING_SNAKE_CASE  )			->		None:
         super().__init__()
         UpperCAmelCase_      :							int       =      [
             nn.AdaptiveAvgPoolad(_SCREAMING_SNAKE_CASE  ),
             UperNetConvModule(_SCREAMING_SNAKE_CASE       ,_SCREAMING_SNAKE_CASE       ,kernel_size=1  ),
         ]
         for i, layer in enumerate(self.layers  ):
              self.add_module(str(_SCREAMING_SNAKE_CASE  )       ,_SCREAMING_SNAKE_CASE  )





    def 							a__				(				self       ,_SCREAMING_SNAKE_CASE  )			->		torch.Tensor:
         UpperCAmelCase_      :							Optional[Any]       =      input
         for layer in self.layers:
              UpperCAmelCase_      :							Union[str, Any]       =      layer(_SCREAMING_SNAKE_CASE  )
         return hidden_state


class   __a(					nn.Module       ):






    """simple docstring"""





    def __init__(				self       ,_SCREAMING_SNAKE_CASE       ,_SCREAMING_SNAKE_CASE       ,_SCREAMING_SNAKE_CASE       ,_SCREAMING_SNAKE_CASE  )			->		None:
         super().__init__()
         UpperCAmelCase_      :							int       =      pool_scales
         UpperCAmelCase_      :							Union[str, Any]       =      align_corners
         UpperCAmelCase_      :							Dict       =      in_channels
         UpperCAmelCase_      :							Dict       =      channels
         UpperCAmelCase_      :							List[str]       =      []
         for i, pool_scale in enumerate(_SCREAMING_SNAKE_CASE  ):
              UpperCAmelCase_      :							Union[str, Any]       =      UperNetPyramidPoolingBlock(pool_scale=_SCREAMING_SNAKE_CASE       ,in_channels=_SCREAMING_SNAKE_CASE       ,channels=_SCREAMING_SNAKE_CASE  )
              self.blocks.append(_SCREAMING_SNAKE_CASE  )
              self.add_module(str(_SCREAMING_SNAKE_CASE  )       ,_SCREAMING_SNAKE_CASE  )





    def 							a__				(				self       ,_SCREAMING_SNAKE_CASE  )			->		List[torch.Tensor]:
         UpperCAmelCase_      :							Union[str, Any]       =      []
         for ppm in self.blocks:
              UpperCAmelCase_      :							Any       =      ppm(_SCREAMING_SNAKE_CASE  )
              UpperCAmelCase_      :							Tuple       =      nn.functional.interpolate(
                  _SCREAMING_SNAKE_CASE       ,size=x.size()[2:]       ,mode='''bilinear'''       ,align_corners=self.align_corners  )
              ppm_outs.append(_SCREAMING_SNAKE_CASE  )
         return ppm_outs


class   __a(					nn.Module       ):






    """simple docstring"""





    def __init__(				self       ,_SCREAMING_SNAKE_CASE       ,_SCREAMING_SNAKE_CASE  )			->		Union[str, Any]:
         super().__init__()

         UpperCAmelCase_      :							List[Any]       =      config
         UpperCAmelCase_      :							Union[str, Any]       =      config.pool_scales  # e.g. (1, 2, 3, 6)
         UpperCAmelCase_      :							int       =      in_channels
         UpperCAmelCase_      :							Optional[Any]       =      config.hidden_size
         UpperCAmelCase_      :							List[Any]       =      False
         UpperCAmelCase_      :							List[str]       =      nn.Convad(self.channels       ,config.num_labels       ,kernel_size=1  )

         # PSP Module
         UpperCAmelCase_      :							Any       =      UperNetPyramidPoolingModule(
             self.pool_scales       ,self.in_channels[-1]       ,self.channels       ,align_corners=self.align_corners       ,)
         UpperCAmelCase_      :							Dict       =      UperNetConvModule(
             self.in_channels[-1] + len(self.pool_scales  ) * self.channels       ,self.channels       ,kernel_size=3       ,padding=1       ,)
         # FPN Module
         UpperCAmelCase_      :							Tuple       =      nn.ModuleList()
         UpperCAmelCase_      :							Union[str, Any]       =      nn.ModuleList()
         for in_channels in self.in_channels[:-1]:  # skip the top layer
              UpperCAmelCase_      :							str       =      UperNetConvModule(_SCREAMING_SNAKE_CASE       ,self.channels       ,kernel_size=1  )
              UpperCAmelCase_      :							Dict       =      UperNetConvModule(self.channels       ,self.channels       ,kernel_size=3       ,padding=1  )
              self.lateral_convs.append(_SCREAMING_SNAKE_CASE  )
              self.fpn_convs.append(_SCREAMING_SNAKE_CASE  )

         UpperCAmelCase_      :							Optional[Any]       =      UperNetConvModule(
             len(self.in_channels  ) * self.channels       ,self.channels       ,kernel_size=3       ,padding=1       ,)





    def 							a__				(				self  )			->		Union[str, Any]:
         self.apply(self._init_weights  )





    def 							a__				(				self       ,_SCREAMING_SNAKE_CASE  )			->		str:
         if isinstance(_SCREAMING_SNAKE_CASE       ,nn.Convad  ):
              module.weight.data.normal_(mean=0.0       ,std=self.config.initializer_range  )
              if module.bias is not None:
                   module.bias.data.zero_()





    def 							a__				(				self       ,_SCREAMING_SNAKE_CASE  )			->		List[Any]:
         UpperCAmelCase_      :							Tuple       =      inputs[-1]
         UpperCAmelCase_      :							Any       =      [x]
         psp_outs.extend(self.psp_modules(_SCREAMING_SNAKE_CASE  )  )
         UpperCAmelCase_      :							List[Any]       =      torch.cat(_SCREAMING_SNAKE_CASE       ,dim=1  )
         UpperCAmelCase_      :							Optional[Any]       =      self.bottleneck(_SCREAMING_SNAKE_CASE  )

         return output





    def 							a__				(				self       ,_SCREAMING_SNAKE_CASE  )			->		torch.Tensor:
         # build laterals
         UpperCAmelCase_      :							int       =      [lateral_conv(encoder_hidden_states[i]  ) for i, lateral_conv in enumerate(self.lateral_convs  )]

         laterals.append(self.psp_forward(_SCREAMING_SNAKE_CASE  )  )

         # build top-down path
         UpperCAmelCase_      :							Optional[Any]       =      len(_SCREAMING_SNAKE_CASE  )
         for i in range(used_backbone_levels - 1       ,0       ,-1  ):
              UpperCAmelCase_      :							Optional[Any]       =      laterals[i - 1].shape[2:]
              UpperCAmelCase_      :							str       =      laterals[i - 1] + nn.functional.interpolate(
                  laterals[i]       ,size=_SCREAMING_SNAKE_CASE       ,mode='''bilinear'''       ,align_corners=self.align_corners  )

         # build outputs
         UpperCAmelCase_      :							Optional[Any]       =      [self.fpn_convs[i](laterals[i]  ) for i in range(used_backbone_levels - 1  )]
         # append psp feature
         fpn_outs.append(laterals[-1]  )

         for i in range(used_backbone_levels - 1       ,0       ,-1  ):
              UpperCAmelCase_      :							Union[str, Any]       =      nn.functional.interpolate(
                  fpn_outs[i]       ,size=fpn_outs[0].shape[2:]       ,mode='''bilinear'''       ,align_corners=self.align_corners  )
         UpperCAmelCase_      :							List[str]       =      torch.cat(_SCREAMING_SNAKE_CASE       ,dim=1  )
         UpperCAmelCase_      :							int       =      self.fpn_bottleneck(_SCREAMING_SNAKE_CASE  )
         UpperCAmelCase_      :							List[Any]       =      self.classifier(_SCREAMING_SNAKE_CASE  )

         return output


class   __a(					nn.Module       ):






    """simple docstring"""





    def __init__(				self       ,_SCREAMING_SNAKE_CASE       ,_SCREAMING_SNAKE_CASE = 2       ,_SCREAMING_SNAKE_CASE = 3       ,_SCREAMING_SNAKE_CASE = 1  )			->		None:
         super().__init__()

         UpperCAmelCase_      :							List[Any]       =      config
         UpperCAmelCase_      :							List[str]       =      config.auxiliary_in_channels
         UpperCAmelCase_      :							Dict       =      config.auxiliary_channels
         UpperCAmelCase_      :							Any       =      config.auxiliary_num_convs
         UpperCAmelCase_      :							List[str]       =      config.auxiliary_concat_input
         UpperCAmelCase_      :							Optional[Any]       =      in_index

         UpperCAmelCase_      :							Optional[int]       =      (kernel_size // 2) * dilation
         UpperCAmelCase_      :							Optional[Any]       =      []
         convs.append(
             UperNetConvModule(
                 self.in_channels       ,self.channels       ,kernel_size=_SCREAMING_SNAKE_CASE       ,padding=_SCREAMING_SNAKE_CASE       ,dilation=_SCREAMING_SNAKE_CASE  )  )
         for i in range(self.num_convs - 1  ):
              convs.append(
                  UperNetConvModule(
                      self.channels       ,self.channels       ,kernel_size=_SCREAMING_SNAKE_CASE       ,padding=_SCREAMING_SNAKE_CASE       ,dilation=_SCREAMING_SNAKE_CASE  )  )
         if self.num_convs == 0:
              UpperCAmelCase_      :							List[str]       =      nn.Identity()
         else:
              UpperCAmelCase_      :							Union[str, Any]       =      nn.Sequential(*_SCREAMING_SNAKE_CASE  )
         if self.concat_input:
              UpperCAmelCase_      :							Tuple       =      UperNetConvModule(
                  self.in_channels + self.channels       ,self.channels       ,kernel_size=_SCREAMING_SNAKE_CASE       ,padding=kernel_size // 2  )

         UpperCAmelCase_      :							Union[str, Any]       =      nn.Convad(self.channels       ,config.num_labels       ,kernel_size=1  )





    def 							a__				(				self  )			->		Dict:
         self.apply(self._init_weights  )





    def 							a__				(				self       ,_SCREAMING_SNAKE_CASE  )			->		List[str]:
         if isinstance(_SCREAMING_SNAKE_CASE       ,nn.Convad  ):
              module.weight.data.normal_(mean=0.0       ,std=self.config.initializer_range  )
              if module.bias is not None:
                   module.bias.data.zero_()





    def 							a__				(				self       ,_SCREAMING_SNAKE_CASE  )			->		torch.Tensor:
         # just take the relevant feature maps
         UpperCAmelCase_      :							Dict       =      encoder_hidden_states[self.in_index]
         UpperCAmelCase_      :							int       =      self.convs(_SCREAMING_SNAKE_CASE  )
         if self.concat_input:
              UpperCAmelCase_      :							Union[str, Any]       =      self.conv_cat(torch.cat([hidden_states, output]       ,dim=1  )  )
         UpperCAmelCase_      :							Optional[int]       =      self.classifier(_SCREAMING_SNAKE_CASE  )
         return output


class   __a(					_a       ):






    """simple docstring"""





    lowerCAmelCase        =				UperNetConfig
    lowerCAmelCase        =				'''pixel_values'''
    lowerCAmelCase        =				True





    def 							a__				(				self       ,_SCREAMING_SNAKE_CASE  )			->		Dict:
         if isinstance(_SCREAMING_SNAKE_CASE       ,_SCREAMING_SNAKE_CASE  ):
              module.backbone.init_weights()
              module.decode_head.init_weights()
              module.auxiliary_head.init_weights()





    def 							a__				(				self  )			->		Any:
         self.backbone.init_weights()
         self.decode_head.init_weights()
         self.auxiliary_head.init_weights()





    def 							a__				(				self       ,_SCREAMING_SNAKE_CASE       ,_SCREAMING_SNAKE_CASE=False  )			->		int:
         if isinstance(_SCREAMING_SNAKE_CASE       ,_SCREAMING_SNAKE_CASE  ):
              UpperCAmelCase_      :							int       =      value


__a          =			R'\n    Parameters:\n    This model is a PyTorch [torch.nn.Module](https://pytorch.org/docs/stable/nn.html#torch.nn.Module) sub-class. Use\n    it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage and\n    behavior.\n        config ([`UperNetConfig`]): Model configuration class with all the parameters of the model.\n            Initializing with a config file does not load the weights associated with the model, only the\n            configuration. Check out the [`~PreTrainedModel.from_pretrained`] method to load the model weights.\n'

__a          =			R'\n    Args:\n        pixel_values (`torch.FloatTensor` of shape `(batch_size, num_channels, height, width)`):\n            Pixel values. Padding will be ignored by default should you provide it. Pixel values can be obtained using\n            [`AutoImageProcessor`]. See [`SegformerImageProcessor.__call__`] for details.\n        output_attentions (`bool`, *optional*):\n            Whether or not to return the attentions tensors of all attention layers in case the backbone has them. See\n            `attentions` under returned tensors for more detail.\n        output_hidden_states (`bool`, *optional*):\n            Whether or not to return the hidden states of all layers of the backbone. See `hidden_states` under\n            returned tensors for more detail.\n        return_dict (`bool`, *optional*):\n            Whether or not to return a [`~utils.ModelOutput`] instead of a plain tuple.\n'

@add_start_docstrings(
    '''UperNet framework leveraging any vision backbone e.g. for ADE20k, CityScapes.'''    ,						_a    ,						)
class   __a(					_a       ):






    """simple docstring"""





    def __init__(				self       ,_SCREAMING_SNAKE_CASE  )			->		int:
         super().__init__(_SCREAMING_SNAKE_CASE  )

         UpperCAmelCase_      :							List[Any]       =      AutoBackbone.from_config(config.backbone_config  )

         # Semantic segmentation head(s)
         UpperCAmelCase_      :							Optional[int]       =      UperNetHead(_SCREAMING_SNAKE_CASE       ,in_channels=self.backbone.channels  )
         UpperCAmelCase_      :							int       =      UperNetFCNHead(_SCREAMING_SNAKE_CASE  ) if config.use_auxiliary_head else None

         # Initialize weights and apply final processing
         self.post_init()





    @add_start_docstrings_to_model_forward(UPERNET_INPUTS_DOCSTRING.format('''batch_size, sequence_length'''  )  )
    @replace_return_docstrings(output_type=_SCREAMING_SNAKE_CASE       ,config_class=_CONFIG_FOR_DOC  )
    def 							a__				(				self       ,_SCREAMING_SNAKE_CASE = None       ,_SCREAMING_SNAKE_CASE = None       ,_SCREAMING_SNAKE_CASE = None       ,_SCREAMING_SNAKE_CASE = None       ,_SCREAMING_SNAKE_CASE = None       ,)			->		Union[tuple, SemanticSegmenterOutput]:
         UpperCAmelCase_      :							Union[str, Any]       =      return_dict if return_dict is not None else self.config.use_return_dict
         UpperCAmelCase_      :							Tuple       =      (
             output_hidden_states if output_hidden_states is not None else self.config.output_hidden_states
         )
         UpperCAmelCase_      :							str       =      output_attentions if output_attentions is not None else self.config.output_attentions

         UpperCAmelCase_      :							str       =      self.backbone.forward_with_filtered_kwargs(
             _SCREAMING_SNAKE_CASE       ,output_hidden_states=_SCREAMING_SNAKE_CASE       ,output_attentions=_SCREAMING_SNAKE_CASE  )
         UpperCAmelCase_      :							Union[str, Any]       =      outputs.feature_maps

         UpperCAmelCase_      :							Optional[int]       =      self.decode_head(_SCREAMING_SNAKE_CASE  )
         UpperCAmelCase_      :							Optional[Any]       =      nn.functional.interpolate(_SCREAMING_SNAKE_CASE       ,size=pixel_values.shape[2:]       ,mode='''bilinear'''       ,align_corners=_SCREAMING_SNAKE_CASE  )

         UpperCAmelCase_      :							Optional[Any]       =      None
         if self.auxiliary_head is not None:
              UpperCAmelCase_      :							str       =      self.auxiliary_head(_SCREAMING_SNAKE_CASE  )
              UpperCAmelCase_      :							Dict       =      nn.functional.interpolate(
                  _SCREAMING_SNAKE_CASE       ,size=pixel_values.shape[2:]       ,mode='''bilinear'''       ,align_corners=_SCREAMING_SNAKE_CASE  )

         UpperCAmelCase_      :							Optional[Any]       =      None
         if labels is not None:
              if self.config.num_labels == 1:
                   raise ValueError('''The number of labels should be greater than one'''  )
              else:
                   # compute weighted loss
                   UpperCAmelCase_      :							Optional[Any]       =      CrossEntropyLoss(ignore_index=self.config.loss_ignore_index  )
                   UpperCAmelCase_      :							Optional[Any]       =      loss_fct(_SCREAMING_SNAKE_CASE       ,_SCREAMING_SNAKE_CASE  )
                   UpperCAmelCase_      :							Optional[Any]       =      loss_fct(_SCREAMING_SNAKE_CASE       ,_SCREAMING_SNAKE_CASE  )
                   UpperCAmelCase_      :							List[str]       =      main_loss + self.config.auxiliary_loss_weight * auxiliary_loss

         if not return_dict:
              if output_hidden_states:
                   UpperCAmelCase_      :							Optional[Any]       =      (logits,) + outputs[1:]
              else:
                   UpperCAmelCase_      :							Tuple       =      (logits,) + outputs[2:]
              return ((loss,) + output) if loss is not None else output

         return SemanticSegmenterOutput(
             loss=_SCREAMING_SNAKE_CASE       ,logits=_SCREAMING_SNAKE_CASE       ,hidden_states=outputs.hidden_states       ,attentions=outputs.attentions       ,)





from dataclasses import dataclass, field
from typing import Optional

@dataclass
class   __a:






    """simple docstring"""





    lowerCAmelCase        =				field(
        default='''codeparrot/codeparrot'''    ,						metadata={'''help''': '''Model name or path of model to be trained.'''}       )
    lowerCAmelCase        =				field(
        default='''./'''    ,						metadata={'''help''': '''Save dir where model repo is cloned and models updates are saved to.'''}       )
    lowerCAmelCase        =				field(
        default='''codeparrot/codeparrot-clean-train'''    ,						metadata={'''help''': '''Name or path of training dataset.'''}       )
    lowerCAmelCase        =				field(
        default='''codeparrot/codeparrot-clean-valid'''    ,						metadata={'''help''': '''Name or path of validation dataset.'''}       )
    lowerCAmelCase        =				field(default=2    ,						metadata={'''help''': '''Batch size for training.'''}       )
    lowerCAmelCase        =				field(default=2    ,						metadata={'''help''': '''Batch size for evaluation.'''}       )
    lowerCAmelCase        =				field(default=0.1    ,						metadata={'''help''': '''Value of weight decay.'''}       )
    lowerCAmelCase        =				field(
        default=1_0000    ,						metadata={'''help''': '''Size of buffer used to shuffle streaming dataset.'''}       )
    lowerCAmelCase        =				field(default=2E-4    ,						metadata={'''help''': '''Learning rate fo training.'''}       )
    lowerCAmelCase        =				field(default='''cosine'''    ,						metadata={'''help''': '''Learning rate.'''}       )
    lowerCAmelCase        =				field(
        default=750    ,						metadata={'''help''': '''Number of warmup steps in the learning rate schedule.'''}       )
    lowerCAmelCase        =				field(
        default=16    ,						metadata={'''help''': '''Number of gradient accumulation steps.'''}       )
    lowerCAmelCase        =				field(
        default=_a    ,						metadata={'''help''': '''Use gradient checkpointing to reduce memory footprint.'''}       )
    lowerCAmelCase        =				field(default=5_0000    ,						metadata={'''help''': '''Maximum number of training steps.'''}       )
    lowerCAmelCase        =				field(
        default=-1    ,						metadata={'''help''': '''Maximum number of evaluation steps. If -1 the full dataset is evaluated.'''}       )
    lowerCAmelCase        =				field(default=1024    ,						metadata={'''help''': '''Sequence lengths used for training.'''}       )
    lowerCAmelCase        =				field(default=1    ,						metadata={'''help''': '''Training seed.'''}       )
    lowerCAmelCase        =				field(
        default=1024    ,						metadata={'''help''': '''Interval to save checkpoints. Measured as number of forward passes not training steps.'''}    ,						)
    lowerCAmelCase        =				field(
        default=_a    ,						metadata={'''help''': '''States path if the training should continue from a checkpoint folder.'''}       )
    lowerCAmelCase        =				field(default=_a    ,						metadata={'''help''': '''If True the data is pretokenized.'''}       )


@dataclass
class   __a:






    """simple docstring"""





    lowerCAmelCase        =				field(
        default='''codeparrot/codeparrot'''    ,						metadata={'''help''': '''Model name or path of model to be evaluated.'''}       )
    lowerCAmelCase        =				field(
        default='''codeparrot/codeparrot-clean-valid'''    ,						metadata={'''help''': '''Name or path of validation dataset.'''}       )
    lowerCAmelCase        =				field(default=2    ,						metadata={'''help''': '''Batch size used for evaluation.'''}       )
    lowerCAmelCase        =				field(
        default=-1    ,						metadata={'''help''': '''Maximum number of evaluation steps. If -1 the full dataset is evaluated.'''}       )
    lowerCAmelCase        =				field(default=1024    ,						metadata={'''help''': '''Length of sequences to be evaluated.'''}       )
    lowerCAmelCase        =				field(default=1    ,						metadata={'''help''': '''Random seed used for evaluation.'''}       )


@dataclass
class   __a:






    """simple docstring"""





    lowerCAmelCase        =				field(
        default='''codeparrot/codeparrot'''    ,						metadata={'''help''': '''Model name or path of model to be evaluated.'''}       )
    lowerCAmelCase        =				field(default=_a    ,						metadata={'''help''': '''Number of workers used for code evaluation.'''}       )
    lowerCAmelCase        =				field(
        default=_a    ,						metadata={'''help''': '''The number of human-eval tasks to run. If not included all tasks are evaluated.'''}    ,						)
    lowerCAmelCase        =				field(
        default=_a    ,						metadata={'''help''': '''Sample from the language model\'s output distribution.'''}       )
    lowerCAmelCase        =				field(default=0.2    ,						metadata={'''help''': '''Sampling temperature used for generation.'''}       )
    lowerCAmelCase        =				field(default=256    ,						metadata={'''help''': '''Maximum number of newly generated tokens.'''}       )
    lowerCAmelCase        =				field(default=0    ,						metadata={'''help''': '''Top-k parameter used for generation.'''}       )
    lowerCAmelCase        =				field(default=0.95    ,						metadata={'''help''': '''Top-p parameter used for nucleus sampling.'''}       )
    lowerCAmelCase        =				field(default=10    ,						metadata={'''help''': '''Number of generations to run in parallel.'''}       )
    lowerCAmelCase        =				field(
        default=200    ,						metadata={'''help''': '''Number of completions to generate for each sample.'''}       )
    lowerCAmelCase        =				field(default=1    ,						metadata={'''help''': '''Random seed used for evaluation.'''}       )
    lowerCAmelCase        =				field(
        default='''eval_results.json'''    ,						metadata={'''help''': '''Random seed used for evaluation.'''}       )
    lowerCAmelCase        =				field(
        default='''0'''    ,						metadata={'''help''': '''Allow `code_eval` to execute Python code on machine'''}       )
    lowerCAmelCase        =				field(
        default=-1    ,						metadata={
            '''help''': (
                '''Determine which device to run the `text-generation` Pipeline on. -1 is CPU and any zero or positive'''
                ''' number corresponds to which GPU device id to run on.'''
            )
        }    ,						)


@dataclass
class   __a:






    """simple docstring"""





    lowerCAmelCase        =				field(
        default=_a    ,						metadata={
            '''help''': '''The number of CPU cores to use for parallel preprocessing. Default uses the maximum available.'''
        }    ,						)
    lowerCAmelCase        =				field(
        default='''transformersbook/codeparrot'''    ,						metadata={'''help''': '''Folder or name of dataset to process.'''}       )
    lowerCAmelCase        =				field(
        default='''codeparrot-clean'''    ,						metadata={'''help''': '''Folder to save processed processed dataset.'''}       )
    lowerCAmelCase        =				field(
        default=10_0000    ,						metadata={'''help''': '''Number of files to save per JSON output file.'''}       )
    lowerCAmelCase        =				field(default='''content'''    ,						metadata={'''help''': '''Column containing text data to process.'''}       )
    lowerCAmelCase        =				field(
        default=1000    ,						metadata={'''help''': '''Maximum line length in file, otherwise file is filtered.'''}       )
    lowerCAmelCase        =				field(
        default=100    ,						metadata={'''help''': '''Maximum mean line length in file, otherwise file is filtered.'''}       )
    lowerCAmelCase        =				field(
        default=0.25    ,						metadata={'''help''': '''Maximum fraction of non-alphanumeric characters, otherwise file is filtered.'''}       )
    lowerCAmelCase        =				field(
        default=1.5    ,						metadata={'''help''': '''Minimum character token ratio for the file, otherwise file is filtered.'''}       )
    lowerCAmelCase        =				field(
        default=0.7    ,						metadata={'''help''': '''Probability for filtering config, test and uncommon files.'''}       )
    lowerCAmelCase        =				field(
        default='''codeparrot/codeparrot'''    ,						metadata={'''help''': '''Name or path to the tokenizer.'''}    ,						)
    lowerCAmelCase        =				field(
        default=_a    ,						metadata={'''help''': '''If True, near-duplicate samples are removed.'''}       )
    lowerCAmelCase        =				field(
        default=0.85    ,						metadata={'''help''': '''Jaccard threshold for near-duplicate samples.'''}       )


@dataclass
class   __a:






    """simple docstring"""





    lowerCAmelCase        =				field(
        default='''gpt2'''    ,						metadata={'''help''': '''Base tokenizer to build new tokenizer from.'''}       )
    lowerCAmelCase        =				field(
        default='''transformersbook/codeparrot-train'''    ,						metadata={'''help''': '''Dataset to train tokenizer on.'''}       )
    lowerCAmelCase        =				field(default='''content'''    ,						metadata={'''help''': '''Column containing text data to process.'''}       )
    lowerCAmelCase        =				field(default=20_0000    ,						metadata={'''help''': '''Number of examples to train tokenizer on.'''}       )
    lowerCAmelCase        =				field(
        default=3_2768    ,						metadata={'''help''': '''Number of examples to train the tokenizer on.'''}       )
    lowerCAmelCase        =				field(default='''codeparrot'''    ,						metadata={'''help''': '''Name of new tokenizer.'''}       )
    lowerCAmelCase        =				field(default=_a    ,						metadata={'''help''': '''Push saved tokenizer to the hub.'''}       )


@dataclass
class   __a:






    """simple docstring"""





    lowerCAmelCase        =				field(
        default='''codeparrot/codeparrot'''    ,						metadata={'''help''': '''Name or path to the tokenizer.'''}       )
    lowerCAmelCase        =				field(
        default='''codeparrot/codeparrot-clean-train'''    ,						metadata={'''help''': '''Name or path to the dataset to pretokenize.'''}       )
    lowerCAmelCase        =				field(
        default='''tokenized-codeparrot-train'''    ,						metadata={'''help''': '''Repo name of the pretokenized data.'''}       )
    lowerCAmelCase        =				field(default=_a    ,						metadata={'''help''': '''Number of workers used for code evaluation.'''}       )


@dataclass
class   __a:






    """simple docstring"""





    lowerCAmelCase        =				field(
        default='''gpt2-large'''    ,						metadata={'''help''': '''Configuration to use for model initialization.'''}       )
    lowerCAmelCase        =				field(
        default='''codeparrot/codeparrot'''    ,						metadata={'''help''': '''Tokenizer attached to model.'''}       )
    lowerCAmelCase        =				field(default='''codeparrot'''    ,						metadata={'''help''': '''Name of the created model.'''}       )
    lowerCAmelCase        =				field(default=_a    ,						metadata={'''help''': '''Push saved tokenizer to the hub.'''}       )