



'''simple docstring'''






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


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

# General docstring
lowerCAmelCase:      str		 =		'UperNetConfig'

class 							a__(      nn.Module			):







    def __init__(   self				:						Tuple		,    __snake_case				:						int		,    __snake_case				:						int		,    __snake_case				:						Union[int, Tuple[int, int]]		,    __snake_case				:						Union[int, Tuple[int, int], str] = 0		,    __snake_case				:						bool = False		,    __snake_case				:						Union[int, Tuple[int, int]] = 1		,    ):
      super().__init__()
      a		:      List[Any]       =  nn.Convad(
          in_channels=__snake_case		,    out_channels=__snake_case		,    kernel_size=__snake_case		,    padding=__snake_case		,    bias=__snake_case		,    dilation=__snake_case		,    )
      a		:      Any       =  nn.BatchNormad(__snake_case			)
      a		:      Optional[Any]       =  nn.ReLU()







    def     lowercase_ (   self				:						List[str]		,    __snake_case				:						torch.Tensor			):
      a		:      int       =  self.conv(__snake_case			)
      a		:      Any       =  self.batch_norm(__snake_case			)
      a		:      Union[str, Any]       =  self.activation(__snake_case			)

      return output

class 							a__(      nn.Module			):







    def __init__(   self				:						List[str]		,    __snake_case				:						int		,    __snake_case				:						int		,    __snake_case				:						int			):
      super().__init__()
      a		:      Optional[int]       =  [
          nn.AdaptiveAvgPoolad(__snake_case			),
          UperNetConvModule(__snake_case		,    __snake_case		,    kernel_size=1			),
      ]
      for i, layer in enumerate(self.layers			):
        self.add_module(str(__snake_case			)		,    __snake_case			)







    def     lowercase_ (   self				:						Union[str, Any]		,    __snake_case				:						torch.Tensor			):
      a		:      Tuple       =  input
      for layer in self.layers:
        a		:      Dict       =  layer(__snake_case			)
      return hidden_state

class 							a__(      nn.Module			):







    def __init__(   self				:						Dict		,    __snake_case				:						Tuple[int, ...]		,    __snake_case				:						int		,    __snake_case				:						int		,    __snake_case				:						bool			):
      super().__init__()
      a		:      Optional[int]       =  pool_scales
      a		:      Optional[Any]       =  align_corners
      a		:      List[str]       =  in_channels
      a		:      Union[str, Any]       =  channels
      a		:      Union[str, Any]       =  []
      for i, pool_scale in enumerate(__snake_case			):
        a		:      str       =  UperNetPyramidPoolingBlock(pool_scale=__snake_case		,    in_channels=__snake_case		,    channels=__snake_case			)
        self.blocks.append(__snake_case			)
        self.add_module(str(__snake_case			)		,    __snake_case			)







    def     lowercase_ (   self				:						List[str]		,    __snake_case				:						torch.Tensor			):
      a		:      Union[str, Any]       =  []
      for ppm in self.blocks:
        a		:      Union[str, Any]       =  ppm(__snake_case			)
        a		:      str       =  nn.functional.interpolate(
            __snake_case		,    size=x.size()[2:]		,    mode='bilinear'		,    align_corners=self.align_corners			)
        ppm_outs.append(__snake_case			)
      return ppm_outs

class 							a__(      nn.Module			):







    def __init__(   self				:						List[Any]		,    __snake_case				:						Any		,    __snake_case				:						Optional[Any]			):
      super().__init__()

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

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

      a		:      Union[str, Any]       =  UperNetConvModule(
          len(self.in_channels			) * self.channels		,    self.channels		,    kernel_size=3		,    padding=1		,    )







    def     lowercase_ (   self				:						Tuple			):
      self.apply(self._init_weights			)







    def     lowercase_ (   self				:						str		,    __snake_case				:						int			):
      if isinstance(__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     lowercase_ (   self				:						List[str]		,    __snake_case				:						List[str]			):
      a		:      Optional[int]       =  inputs[-1]
      a		:      Tuple       =  [x]
      psp_outs.extend(self.psp_modules(__snake_case			)			)
      a		:      List[str]       =  torch.cat(__snake_case		,    dim=1			)
      a		:      Any       =  self.bottleneck(__snake_case			)

      return output







    def     lowercase_ (   self				:						List[Any]		,    __snake_case				:						torch.Tensor			):
      # build laterals
      a		:      List[str]       =  [lateral_conv(encoder_hidden_states[i]			) for i, lateral_conv in enumerate(self.lateral_convs			)]

      laterals.append(self.psp_forward(__snake_case			)			)

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

      # build outputs
      a		:      int       =  [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			):
        a		:      Tuple       =  nn.functional.interpolate(
            fpn_outs[i]		,    size=fpn_outs[0].shape[2:]		,    mode='bilinear'		,    align_corners=self.align_corners			)
      a		:      Any       =  torch.cat(__snake_case		,    dim=1			)
      a		:      int       =  self.fpn_bottleneck(__snake_case			)
      a		:      int       =  self.classifier(__snake_case			)

      return output

class 							a__(      nn.Module			):







    def __init__(   self				:						Any		,    __snake_case				:						Any		,    __snake_case				:						int = 2		,    __snake_case				:						int = 3		,    __snake_case				:						Union[int, Tuple[int, int]] = 1			):
      super().__init__()

      a		:      int       =  config
      a		:      Optional[Any]       =  config.auxiliary_in_channels
      a		:      Union[str, Any]       =  config.auxiliary_channels
      a		:      Optional[int]       =  config.auxiliary_num_convs
      a		:      Optional[Any]       =  config.auxiliary_concat_input
      a		:      str       =  in_index

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

      a		:      Tuple       =  nn.Convad(self.channels		,    config.num_labels		,    kernel_size=1			)







    def     lowercase_ (   self				:						List[Any]			):
      self.apply(self._init_weights			)







    def     lowercase_ (   self				:						Optional[int]		,    __snake_case				:						Dict			):
      if isinstance(__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     lowercase_ (   self				:						Union[str, Any]		,    __snake_case				:						torch.Tensor			):
      # just take the relevant feature maps
      a		:      str       =  encoder_hidden_states[self.in_index]
      a		:      Optional[int]       =  self.convs(__snake_case			)
      if self.concat_input:
        a		:      int       =  self.conv_cat(torch.cat([hidden_states, output]		,    dim=1			)			)
      a		:      str       =  self.classifier(__snake_case			)
      return output

class 							a__(      __lowercase			):
    lowercase__				=					UperNetConfig
    lowercase__				=					"""pixel_values"""
    lowercase__				=					True







    def     lowercase_ (   self				:						Tuple		,    __snake_case				:						List[Any]			):
      if isinstance(__snake_case		,    __snake_case			):
        module.backbone.init_weights()
        module.decode_head.init_weights()
        module.auxiliary_head.init_weights()







    def     lowercase_ (   self				:						Dict			):
      self.backbone.init_weights()
      self.decode_head.init_weights()
      self.auxiliary_head.init_weights()







    def     lowercase_ (   self				:						List[str]		,    __snake_case				:						List[Any]		,    __snake_case				:						Optional[Any]=False			):
      if isinstance(__snake_case		,    __snake_case			):
        a		:      Tuple       =  value
lowerCAmelCase:      Dict		 =		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'

lowerCAmelCase:      Dict		 =		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."""	,				__lowercase	,				)
class 							a__(      __lowercase			):







    def __init__(   self				:						int		,    __snake_case				:						Tuple			):
      super().__init__(__snake_case			)

      a		:      Union[str, Any]       =  AutoBackbone.from_config(config.backbone_config			)

      # Semantic segmentation head(s)
      a		:      int       =  UperNetHead(__snake_case		,    in_channels=self.backbone.channels			)
      a		:      Any       =  UperNetFCNHead(__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=__snake_case		,    config_class=_CONFIG_FOR_DOC			)
    def     lowercase_ (   self				:						Any		,    __snake_case				:						Optional[torch.Tensor] = None		,    __snake_case				:						Optional[bool] = None		,    __snake_case				:						Optional[bool] = None		,    __snake_case				:						Optional[torch.Tensor] = None		,    __snake_case				:						Optional[bool] = None		,    ):
      a		:      Union[str, Any]       =  return_dict if return_dict is not None else self.config.use_return_dict
      a		:      Tuple       =  (
          output_hidden_states if output_hidden_states is not None else self.config.output_hidden_states
      )
      a		:      Union[str, Any]       =  output_attentions if output_attentions is not None else self.config.output_attentions

      a		:      int       =  self.backbone.forward_with_filtered_kwargs(
          __snake_case		,    output_hidden_states=__snake_case		,    output_attentions=__snake_case			)
      a		:      Optional[Any]       =  outputs.feature_maps

      a		:      str       =  self.decode_head(__snake_case			)
      a		:      List[str]       =  nn.functional.interpolate(__snake_case		,    size=pixel_values.shape[2:]		,    mode='bilinear'		,    align_corners=__snake_case			)

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

      a		:      int       =  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
          a		:      Any       =  CrossEntropyLoss(ignore_index=self.config.loss_ignore_index			)
          a		:      Optional[Any]       =  loss_fct(__snake_case		,    __snake_case			)
          a		:      Optional[int]       =  loss_fct(__snake_case		,    __snake_case			)
          a		:      Tuple       =  main_loss + self.config.auxiliary_loss_weight * auxiliary_loss

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

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










'''simple docstring'''






from typing import Dict, List, Optional, Union

import numpy as np

from .feature_extraction_utils import BatchFeature, FeatureExtractionMixin
from .utils import PaddingStrategy, TensorType, is_tf_tensor, is_torch_tensor, logging, to_numpy


lowerCAmelCase:      int		 =		logging.get_logger(__name__)

class 							a__(      lowerCamelCase__			):







    def __init__(   self				:						Union[str, Any]		,    __snake_case				:						int		,    __snake_case				:						int		,    __snake_case				:						float		,    **__snake_case				:						Optional[int]			):
      a		:      Optional[Any]       =  feature_size
      a		:      Tuple       =  sampling_rate
      a		:      str       =  padding_value

      a		:      Any       =  kwargs.pop('padding_side'		,    'right'			)
      a		:      Tuple       =  kwargs.pop('return_attention_mask'		,    __snake_case			)

      super().__init__(**__snake_case			)







    def     lowercase_ (   self				:						Tuple		,    __snake_case				:						Union[
            BatchFeature,
            List[BatchFeature],
            Dict[str, BatchFeature],
            Dict[str, List[BatchFeature]],
            List[Dict[str, BatchFeature]],
        ]		,    __snake_case				:						Union[bool, str, PaddingStrategy] = True		,    __snake_case				:						Optional[int] = None		,    __snake_case				:						bool = False		,    __snake_case				:						Optional[int] = None		,    __snake_case				:						Optional[bool] = None		,    __snake_case				:						Optional[Union[str, TensorType]] = None		,    ):
      # If we have a list of dicts, let's convert it in a dict of lists
      # We do this to allow using this method as a collate_fn function in PyTorch Dataloader
      if isinstance(__snake_case		,    (list, tuple)			) and isinstance(processed_features[0]		,    (dict, BatchFeature)			):
        a		:      Union[str, Any]       =  {
            key: [example[key] for example in processed_features] for key in processed_features[0].keys()
        }

      # The model's main input name, usually `input_values`, has be passed for padding
      if self.model_input_names[0] not in processed_features:
        raise ValueError(
            'You should supply an instance of `transformers.BatchFeature` or list of `transformers.BatchFeature`'
            F""" to this method that includes {self.model_input_names[0]}, but you provided"""
            F""" {list(processed_features.keys()			)}"""			)

      a		:      Tuple       =  processed_features[self.model_input_names[0]]
      a		:      str       =  (
          return_attention_mask if return_attention_mask is not None else self.return_attention_mask
      )

      if len(__snake_case			) == 0:
        if return_attention_mask:
          a		:      Dict       =  []
        return processed_features

      # If we have PyTorch/TF tensors or lists as inputs, we cast them as Numpy arrays
      # and rebuild them afterwards if no return_tensors is specified
      # Note that we lose the specific device the tensor may be on for PyTorch

      a		:      Optional[int]       =  required_input[0]
      if isinstance(__snake_case		,    (list, tuple)			):
        # first_element might be an empty list/tuple in some edge cases so we grab the first non empty element.
        a		:      Dict       =  0
        while len(required_input[index]			) == 0:
          index += 1
        if index < len(__snake_case			):
          a		:      Tuple       =  required_input[index][0]

      if return_tensors is None:
        if is_tf_tensor(__snake_case			):
          a		:      Any       =  'tf'
        elif is_torch_tensor(__snake_case			):
          a		:      Optional[Any]       =  'pt'
        elif isinstance(__snake_case		,    (int, float, list, tuple, np.ndarray)			):
          a		:      List[Any]       =  'np'
        else:
          raise ValueError(
              F"""type of {first_element} unknown: {type(__snake_case			)}. """
              'Should be one of a python, numpy, pytorch or tensorflow object.'			)

      for key, value in processed_features.items():
        if isinstance(value[0]		,    (int, float)			):
          a		:      List[Any]       =  to_numpy(__snake_case			)
        else:
          a		:      Tuple       =  [to_numpy(__snake_case			) for v in value]

        # Convert padding_strategy in PaddingStrategy
      a		:      Any       =  self._get_padding_strategies(padding=__snake_case		,    max_length=__snake_case			)

      a		:      int       =  processed_features[self.model_input_names[0]]

      a		:      Dict       =  len(__snake_case			)
      if not all(len(__snake_case			) == batch_size for v in processed_features.values()			):
        raise ValueError('Some items in the output dictionary have a different batch size than others.'			)

      a		:      Optional[int]       =  []
      for i in range(__snake_case			):
        a		:      int       =  {k: v[i] for k, v in processed_features.items()}
        # truncation
        a		:      List[str]       =  self._truncate(
            __snake_case		,    max_length=__snake_case		,    pad_to_multiple_of=__snake_case		,    truncation=__snake_case		,    )
        truncated_inputs.append(__snake_case			)

      if padding_strategy == PaddingStrategy.LONGEST:
        # make sure that `max_length` cannot be longer than the longest truncated length
        a		:      List[str]       =  max(len(input_slice[self.model_input_names[0]]			) for input_slice in truncated_inputs			)
        a		:      Tuple       =  PaddingStrategy.MAX_LENGTH

      a		:      int       =  {}
      for i in range(__snake_case			):
        # padding
        a		:      int       =  self._pad(
            truncated_inputs[i]		,    max_length=__snake_case		,    padding_strategy=__snake_case		,    pad_to_multiple_of=__snake_case		,    return_attention_mask=__snake_case		,    )

        for key, value in outputs.items():
          if key not in batch_outputs:
            a		:      int       =  []
          if value.dtype is np.dtype(np.floataa			):
            a		:      List[str]       =  value.astype(np.floataa			)
          batch_outputs[key].append(__snake_case			)

      return BatchFeature(__snake_case		,    tensor_type=__snake_case			)







    def     lowercase_ (   self				:						List[str]		,    __snake_case				:						Union[Dict[str, np.ndarray], BatchFeature]		,    __snake_case				:						Optional[int] = None		,    __snake_case				:						PaddingStrategy = PaddingStrategy.DO_NOT_PAD		,    __snake_case				:						Optional[int] = None		,    __snake_case				:						Optional[bool] = None		,    ):
      a		:      List[str]       =  processed_features[self.model_input_names[0]]

      if padding_strategy == PaddingStrategy.LONGEST:
        a		:      Any       =  len(__snake_case			)

      if max_length is not None and pad_to_multiple_of is not None and (max_length % pad_to_multiple_of != 0):
        a		:      Dict       =  ((max_length // pad_to_multiple_of) + 1) * pad_to_multiple_of

      a		:      List[Any]       =  padding_strategy != PaddingStrategy.DO_NOT_PAD and len(__snake_case			) < max_length

      if return_attention_mask and "attention_mask" not in processed_features:
        a		:      Union[str, Any]       =  np.ones(len(__snake_case			)		,    dtype=np.intaa			)

      if needs_to_be_padded:
        a		:      Tuple       =  max_length - len(__snake_case			)
        if self.padding_side == "right":
          if return_attention_mask:
            a		:      Any       =  np.pad(
                processed_features['attention_mask']		,    (0, difference)			)
          a		:      Optional[Any]       =  ((0, difference), (0, 0)) if self.feature_size > 1 else (0, difference)
          a		:      Optional[int]       =  np.pad(
              __snake_case		,    __snake_case		,    'constant'		,    constant_values=self.padding_value			)
        elif self.padding_side == "left":
          if return_attention_mask:
            a		:      Optional[int]       =  np.pad(
                processed_features['attention_mask']		,    (difference, 0)			)
          a		:      Optional[Any]       =  ((difference, 0), (0, 0)) if self.feature_size > 1 else (difference, 0)
          a		:      List[Any]       =  np.pad(
              __snake_case		,    __snake_case		,    'constant'		,    constant_values=self.padding_value			)
        else:
          raise ValueError('Invalid padding strategy:' + str(self.padding_side			)			)

      return processed_features







    def     lowercase_ (   self				:						List[str]		,    __snake_case				:						Union[Dict[str, np.ndarray], BatchFeature]		,    __snake_case				:						Optional[int] = None		,    __snake_case				:						Optional[int] = None		,    __snake_case				:						Optional[bool] = None		,    ):
      if not truncation:
        return processed_features
      elif truncation and max_length is None:
        raise ValueError('When setting ``truncation=True``, make sure that ``max_length`` is defined.'			)

      a		:      Dict       =  processed_features[self.model_input_names[0]]

      # find `max_length` that fits `pad_to_multiple_of`
      if max_length is not None and pad_to_multiple_of is not None and (max_length % pad_to_multiple_of != 0):
        a		:      Optional[Any]       =  ((max_length // pad_to_multiple_of) + 1) * pad_to_multiple_of

      a		:      str       =  len(__snake_case			) > max_length

      if needs_to_be_truncated:
        a		:      str       =  processed_features[self.model_input_names[0]][:max_length]
        if "attention_mask" in processed_features:
          a		:      List[str]       =  processed_features['attention_mask'][:max_length]

      return processed_features







    def     lowercase_ (   self				:						Dict		,    __snake_case				:						Optional[Any]=False		,    __snake_case				:						Optional[int]=None			):

      # Get padding strategy
      if padding is not False:
        if padding is True:
          a		:      Union[str, Any]       =  PaddingStrategy.LONGEST  # Default to pad to the longest sequence in the batch
        elif not isinstance(__snake_case		,    __snake_case			):
          a		:      List[Any]       =  PaddingStrategy(__snake_case			)
        elif isinstance(__snake_case		,    __snake_case			):
          a		:      List[str]       =  padding
      else:
        a		:      Dict       =  PaddingStrategy.DO_NOT_PAD

      # Set max length if needed
      if max_length is None:
        if padding_strategy == PaddingStrategy.MAX_LENGTH:
          raise ValueError(
              F"""When setting ``padding={PaddingStrategy.MAX_LENGTH}``, make sure that max_length is defined"""			)

        # Test if we have a padding value
      if padding_strategy != PaddingStrategy.DO_NOT_PAD and (self.padding_value is None):
        raise ValueError(
            'Asking to pad but the feature_extractor does not have a padding value. Please select a value to use'
            ' as `padding_value`. For example: `feature_extractor.padding_value = 0.0`.'			)

      return padding_strategy