



'''simple docstring'''






import argparse
import json

import requests
import torch
from huggingface_hub import hf_hub_download
from PIL import Image

from transformers import SegformerImageProcessor, SwinConfig, UperNetConfig, UperNetForSemanticSegmentation
def    lowerCamelCase__ (		_A       ):
  a		:      Optional[int]       =  384
  a		:      Dict       =  7
  if "tiny" in model_name:
    a		:      Any       =  96
    a		:      int       =  (2, 2, 6, 2)
    a		:      Union[str, Any]       =  (3, 6, 12, 24)
  elif "small" in model_name:
    a		:      str       =  96
    a		:      Any       =  (2, 2, 18, 2)
    a		:      Any       =  (3, 6, 12, 24)
  elif "base" in model_name:
    a		:      Optional[int]       =  128
    a		:      int       =  (2, 2, 18, 2)
    a		:      Any       =  (4, 8, 16, 32)
    a		:      str       =  12
    a		:      List[Any]       =  512
  elif "large" in model_name:
    a		:      int       =  192
    a		:      Optional[Any]       =  (2, 2, 18, 2)
    a		:      List[Any]       =  (6, 12, 24, 48)
    a		:      List[Any]       =  12
    a		:      List[Any]       =  768

  # set label information
  a		:      List[Any]       =  150
  a		:      Dict       =  'huggingface/label-files'
  a		:      Union[str, Any]       =  'ade20k-id2label.json'
  a		:      Union[str, Any]       =  json.load(open(hf_hub_download(_A				,    _A				,    repo_type='dataset'       )				,    'r'       )       )
  a		:      Optional[int]       =  {int(_A       ): v for k, v in idalabel.items()}
  a		:      Tuple       =  {v: k for k, v in idalabel.items()}

  a		:      Optional[int]       =  SwinConfig(
      embed_dim=_A				,    depths=_A				,    num_heads=_A				,    window_size=_A				,    out_features=['stage1', 'stage2', 'stage3', 'stage4']				,    )
  a		:      int       =  UperNetConfig(
      backbone_config=_A				,    auxiliary_in_channels=_A				,    num_labels=_A				,    idalabel=_A				,    labelaid=_A				,    )

  return config
def    lowerCamelCase__ (		_A       ):
  a		:      List[Any]       =  []

  # fmt: off
  # stem
  rename_keys.append(('backbone.patch_embed.projection.weight', 'backbone.embeddings.patch_embeddings.projection.weight')       )
  rename_keys.append(('backbone.patch_embed.projection.bias', 'backbone.embeddings.patch_embeddings.projection.bias')       )
  rename_keys.append(('backbone.patch_embed.norm.weight', 'backbone.embeddings.norm.weight')       )
  rename_keys.append(('backbone.patch_embed.norm.bias', 'backbone.embeddings.norm.bias')       )
  # stages
  for i in range(len(config.backbone_config.depths       )       ):
    for j in range(config.backbone_config.depths[i]       ):
      rename_keys.append((f"""backbone.stages.{i}.blocks.{j}.norm1.weight""", f"""backbone.encoder.layers.{i}.blocks.{j}.layernorm_before.weight""")       )
      rename_keys.append((f"""backbone.stages.{i}.blocks.{j}.norm1.bias""", f"""backbone.encoder.layers.{i}.blocks.{j}.layernorm_before.bias""")       )
      rename_keys.append((f"""backbone.stages.{i}.blocks.{j}.attn.w_msa.relative_position_bias_table""", f"""backbone.encoder.layers.{i}.blocks.{j}.attention.self.relative_position_bias_table""")       )
      rename_keys.append((f"""backbone.stages.{i}.blocks.{j}.attn.w_msa.relative_position_index""", f"""backbone.encoder.layers.{i}.blocks.{j}.attention.self.relative_position_index""")       )
      rename_keys.append((f"""backbone.stages.{i}.blocks.{j}.attn.w_msa.proj.weight""", f"""backbone.encoder.layers.{i}.blocks.{j}.attention.output.dense.weight""")       )
      rename_keys.append((f"""backbone.stages.{i}.blocks.{j}.attn.w_msa.proj.bias""", f"""backbone.encoder.layers.{i}.blocks.{j}.attention.output.dense.bias""")       )
      rename_keys.append((f"""backbone.stages.{i}.blocks.{j}.norm2.weight""", f"""backbone.encoder.layers.{i}.blocks.{j}.layernorm_after.weight""")       )
      rename_keys.append((f"""backbone.stages.{i}.blocks.{j}.norm2.bias""", f"""backbone.encoder.layers.{i}.blocks.{j}.layernorm_after.bias""")       )
      rename_keys.append((f"""backbone.stages.{i}.blocks.{j}.ffn.layers.0.0.weight""", f"""backbone.encoder.layers.{i}.blocks.{j}.intermediate.dense.weight""")       )
      rename_keys.append((f"""backbone.stages.{i}.blocks.{j}.ffn.layers.0.0.bias""", f"""backbone.encoder.layers.{i}.blocks.{j}.intermediate.dense.bias""")       )
      rename_keys.append((f"""backbone.stages.{i}.blocks.{j}.ffn.layers.1.weight""", f"""backbone.encoder.layers.{i}.blocks.{j}.output.dense.weight""")       )
      rename_keys.append((f"""backbone.stages.{i}.blocks.{j}.ffn.layers.1.bias""", f"""backbone.encoder.layers.{i}.blocks.{j}.output.dense.bias""")       )

    if i < 3:
      rename_keys.append((f"""backbone.stages.{i}.downsample.reduction.weight""", f"""backbone.encoder.layers.{i}.downsample.reduction.weight""")       )
      rename_keys.append((f"""backbone.stages.{i}.downsample.norm.weight""", f"""backbone.encoder.layers.{i}.downsample.norm.weight""")       )
      rename_keys.append((f"""backbone.stages.{i}.downsample.norm.bias""", f"""backbone.encoder.layers.{i}.downsample.norm.bias""")       )
    rename_keys.append((f"""backbone.norm{i}.weight""", f"""backbone.hidden_states_norms.stage{i+1}.weight""")       )
    rename_keys.append((f"""backbone.norm{i}.bias""", f"""backbone.hidden_states_norms.stage{i+1}.bias""")       )

  # decode head
  rename_keys.extend(
      [
          ('decode_head.conv_seg.weight', 'decode_head.classifier.weight'),
          ('decode_head.conv_seg.bias', 'decode_head.classifier.bias'),
          ('auxiliary_head.conv_seg.weight', 'auxiliary_head.classifier.weight'),
          ('auxiliary_head.conv_seg.bias', 'auxiliary_head.classifier.bias'),
      ]       )
  # fmt: on

  return rename_keys
def    lowerCamelCase__ (		_A				,    _A				,    _A       ):
  a		:      Optional[Any]       =  dct.pop(_A       )
  a		:      Any       =  val
def    lowerCamelCase__ (		_A				,    _A       ):
  a		:      str       =  [int(backbone_config.embed_dim * 2**i       ) for i in range(len(backbone_config.depths       )       )]
  for i in range(len(backbone_config.depths       )       ):
    a		:      List[Any]       =  num_features[i]
    for j in range(backbone_config.depths[i]       ):
      # fmt: off
      # read in weights + bias of input projection layer (in original implementation, this is a single matrix + bias)
      a		:      Optional[int]       =  state_dict.pop(f"""backbone.stages.{i}.blocks.{j}.attn.w_msa.qkv.weight"""       )
      a		:      Any       =  state_dict.pop(f"""backbone.stages.{i}.blocks.{j}.attn.w_msa.qkv.bias"""       )
      # next, add query, keys and values (in that order) to the state dict
      a		:      Dict       =  in_proj_weight[:dim, :]
      a		:      Optional[Any]       =  in_proj_bias[: dim]
      a		:      int       =  in_proj_weight[
          dim : dim * 2, :
      ]
      a		:      Union[str, Any]       =  in_proj_bias[
          dim : dim * 2
      ]
      a		:      List[str]       =  in_proj_weight[
          -dim :, :
      ]
      a		:      Tuple       =  in_proj_bias[-dim :]
      # fmt: on
def    lowerCamelCase__ (		_A       ):
  a		:      str       =  x.shape
  a		:      List[Any]       =  x.reshape(_A				,    4				,    in_channel // 4       )
  a		:      Tuple       =  x[:, [0, 2, 1, 3], :].transpose(1				,    2       ).reshape(_A				,    _A       )
  return x
def    lowerCamelCase__ (		_A       ):
  a		:      int       =  x.shape
  a		:      List[Any]       =  x.reshape(_A				,    in_channel // 4				,    4       )
  a		:      Union[str, Any]       =  x[:, :, [0, 2, 1, 3]].transpose(1				,    2       ).reshape(_A				,    _A       )

  return x
def    lowerCamelCase__ (		_A       ):
  a		:      Optional[int]       =  x.shape[0]
  a		:      Optional[int]       =  x.reshape(4				,    in_channel // 4       )
  a		:      List[str]       =  x[[0, 2, 1, 3], :].transpose(0				,    1       ).reshape(_A       )
  return x
def    lowerCamelCase__ (		_A       ):
  a		:      Tuple       =  x.shape[0]
  a		:      str       =  x.reshape(in_channel // 4				,    4       )
  a		:      Tuple       =  x[:, [0, 2, 1, 3]].transpose(0				,    1       ).reshape(_A       )
  return x
def    lowerCamelCase__ (		_A				,    _A				,    _A       ):
  a		:      Optional[int]       =  {
      'upernet-swin-tiny': 'https://download.openmmlab.com/mmsegmentation/v0.5/swin/upernet_swin_tiny_patch4_window7_512x512_160k_ade20k_pretrain_224x224_1K/upernet_swin_tiny_patch4_window7_512x512_160k_ade20k_pretrain_224x224_1K_20210531_112542-e380ad3e.pth',
      'upernet-swin-small': 'https://download.openmmlab.com/mmsegmentation/v0.5/swin/upernet_swin_small_patch4_window7_512x512_160k_ade20k_pretrain_224x224_1K/upernet_swin_small_patch4_window7_512x512_160k_ade20k_pretrain_224x224_1K_20210526_192015-ee2fff1c.pth',
      'upernet-swin-base': 'https://download.openmmlab.com/mmsegmentation/v0.5/swin/upernet_swin_base_patch4_window12_512x512_160k_ade20k_pretrain_384x384_22K/upernet_swin_base_patch4_window12_512x512_160k_ade20k_pretrain_384x384_22K_20210531_125459-429057bf.pth',
      'upernet-swin-large': 'https://download.openmmlab.com/mmsegmentation/v0.5/swin/upernet_swin_large_patch4_window12_512x512_pretrain_384x384_22K_160k_ade20k/upernet_swin_large_patch4_window12_512x512_pretrain_384x384_22K_160k_ade20k_20220318_091743-9ba68901.pth',
  }
  a		:      Optional[Any]       =  model_name_to_url[model_name]
  a		:      Tuple       =  torch.hub.load_state_dict_from_url(_A				,    map_location='cpu'				,    file_name=_A       )[
      'state_dict'
  ]

  for name, param in state_dict.items():
    print(_A				,    param.shape       )

  a		:      List[str]       =  get_upernet_config(_A       )
  a		:      Any       =  UperNetForSemanticSegmentation(_A       )
  model.eval()

  # replace "bn" => "batch_norm"
  for key in state_dict.copy().keys():
    a		:      Any       =  state_dict.pop(_A       )
    if "bn" in key:
      a		:      Dict       =  key.replace('bn'				,    'batch_norm'       )
    a		:      Tuple       =  val

  # rename keys
  a		:      Union[str, Any]       =  create_rename_keys(_A       )
  for src, dest in rename_keys:
    rename_key(_A				,    _A				,    _A       )
  read_in_q_k_v(_A				,    config.backbone_config       )

  # fix downsample parameters
  for key, value in state_dict.items():
    if "downsample" in key:
      if "reduction" in key:
        a		:      int       =  reverse_correct_unfold_reduction_order(_A       )
      if "norm" in key:
        a		:      Dict       =  reverse_correct_unfold_norm_order(_A       )

  model.load_state_dict(_A       )

  # verify on image
  a		:      int       =  'https://huggingface.co/datasets/hf-internal-testing/fixtures_ade20k/resolve/main/ADE_val_00000001.jpg'
  a		:      List[str]       =  Image.open(requests.get(_A				,    stream=_A       ).raw       ).convert('RGB'       )

  a		:      List[Any]       =  SegformerImageProcessor()
  a		:      Optional[int]       =  processor(_A				,    return_tensors='pt'       ).pixel_values

  with torch.no_grad():
    a		:      Dict       =  model(_A       )
    a		:      Tuple       =  outputs.logits

  print(logits.shape       )
  print('First values of logits:'				,    logits[0, 0, :3, :3]       )
  # assert values
  if model_name == "upernet-swin-tiny":
    a		:      Union[str, Any]       =  torch.tensor(
        [[-7.5958, -7.5958, -7.4302], [-7.5958, -7.5958, -7.4302], [-7.4797, -7.4797, -7.3068]]       )
  elif model_name == "upernet-swin-small":
    a		:      Dict       =  torch.tensor(
        [[-7.1921, -7.1921, -6.9532], [-7.1921, -7.1921, -6.9532], [-7.0908, -7.0908, -6.8534]]       )
  elif model_name == "upernet-swin-base":
    a		:      int       =  torch.tensor(
        [[-6.5851, -6.5851, -6.4330], [-6.5851, -6.5851, -6.4330], [-6.4763, -6.4763, -6.3254]]       )
  elif model_name == "upernet-swin-large":
    a		:      Optional[Any]       =  torch.tensor(
        [[-7.5297, -7.5297, -7.3802], [-7.5297, -7.5297, -7.3802], [-7.4044, -7.4044, -7.2586]]       )
  print('Logits:'				,    outputs.logits[0, 0, :3, :3]       )
  assert torch.allclose(outputs.logits[0, 0, :3, :3]				,    _A				,    atol=1E-4       )
  print('Looks ok!'       )

  if pytorch_dump_folder_path is not None:
    print(f"""Saving model {model_name} to {pytorch_dump_folder_path}"""       )
    model.save_pretrained(_A       )
    print(f"""Saving processor to {pytorch_dump_folder_path}"""       )
    processor.save_pretrained(_A       )

  if push_to_hub:
    print(f"""Pushing model and processor for {model_name} to hub"""       )
    model.push_to_hub(f"""openmmlab/{model_name}"""       )
    processor.push_to_hub(f"""openmmlab/{model_name}"""       )


if __name__ == "__main__":
     lowerCAmelCase:      Dict		 =		argparse.ArgumentParser()
     # Required parameters
     parser.add_argument(
         '--model_name',
         default='upernet-swin-tiny',
         type=str,
         choices=[F"upernet-swin-{size}" for size in ['tiny', 'small', 'base', 'large']],
         help='Name of the Swin + UperNet model you\'d like to convert.',
     )
     parser.add_argument(
         '--pytorch_dump_folder_path', default=None, type=str, help='Path to the output PyTorch model directory.'
     )
     parser.add_argument(
         '--push_to_hub', action='store_true', help='Whether or not to push the converted model to the 🤗 hub.'
     )

     lowerCAmelCase:      Tuple		 =		parser.parse_args()
     convert_upernet_checkpoint(args.model_name, args.pytorch_dump_folder_path, args.push_to_hub)










'''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