
"""simple docstring"""





import math

import torch
from torch import nn

from ..configuration_utils import ConfigMixin, register_to_config
from .attention_processor import Attention
from .embeddings import get_timestep_embedding
from .modeling_utils import ModelMixin
class 						SCREAMING_SNAKE_CASE_ (						__a     ,				__a ):




		"""simple docstring"""





		@register_to_config
		def __init__(     self							,  lowerCAmelCase__ = 1_2_8							,  lowerCAmelCase__ = 2_5_6							,  lowerCAmelCase__ = 20_00.0							,  lowerCAmelCase__ = 7_6_8							,  lowerCAmelCase__ = 1_2							,  lowerCAmelCase__ = 1_2							,  lowerCAmelCase__ = 6_4							,  lowerCAmelCase__ = 2_0_4_8							,  lowerCAmelCase__ = 0.1							,  ):
				super().__init__()

				__SCREAMING_SNAKE_CASE            = nn.Sequential(
				    nn.Linear(lowerCAmelCase__							,  d_model * 4							,  bias=lowerCAmelCase__)							,  nn.SiLU()							,  nn.Linear(d_model * 4							,  d_model * 4							,  bias=lowerCAmelCase__)							,  nn.SiLU()							,  )

				__SCREAMING_SNAKE_CASE            = nn.Embedding(lowerCAmelCase__							,  lowerCAmelCase__)
				__SCREAMING_SNAKE_CASE            = False

				__SCREAMING_SNAKE_CASE            = nn.Linear(lowerCAmelCase__							,  lowerCAmelCase__							,  bias=lowerCAmelCase__)

				__SCREAMING_SNAKE_CASE            = nn.Dropout(p=lowerCAmelCase__)

				__SCREAMING_SNAKE_CASE            = nn.ModuleList()
				for lyr_num in range(lowerCAmelCase__):
						# FiLM conditional T5 decoder
						__SCREAMING_SNAKE_CASE            = DecoderLayer(d_model=lowerCAmelCase__							,  d_kv=lowerCAmelCase__							,  num_heads=lowerCAmelCase__							,  d_ff=lowerCAmelCase__							,  dropout_rate=lowerCAmelCase__)
						self.decoders.append(lowerCAmelCase__)

				__SCREAMING_SNAKE_CASE            = TaLayerNorm(lowerCAmelCase__)

				__SCREAMING_SNAKE_CASE            = nn.Dropout(p=lowerCAmelCase__)
				__SCREAMING_SNAKE_CASE            = nn.Linear(lowerCAmelCase__							,  lowerCAmelCase__							,  bias=lowerCAmelCase__)




		def 	snake_case_     (     self							,  lowerCAmelCase__							,  lowerCAmelCase__):
				__SCREAMING_SNAKE_CASE            = torch.mul(query_input.unsqueeze(-1)							,  key_input.unsqueeze(-2))
				return mask.unsqueeze(-3)




		def 	snake_case_     (     self							,  lowerCAmelCase__							,  lowerCAmelCase__							,  lowerCAmelCase__):
				__SCREAMING_SNAKE_CASE       ,__SCREAMING_SNAKE_CASE       ,__SCREAMING_SNAKE_CASE            = decoder_input_tokens.shape
				assert decoder_noise_time.shape == (batch,)

				# decoder_noise_time is in [0, 1), so rescale to expected timing range.
				__SCREAMING_SNAKE_CASE            = get_timestep_embedding(
				    decoder_noise_time * self.config.max_decoder_noise_time							,  embedding_dim=self.config.d_model							,  max_period=self.config.max_decoder_noise_time							,  ).to(dtype=self.dtype)

				__SCREAMING_SNAKE_CASE            = self.conditioning_emb(lowerCAmelCase__).unsqueeze(1)

				assert conditioning_emb.shape == (batch, 1, self.config.d_model * 4)

				__SCREAMING_SNAKE_CASE            = decoder_input_tokens.shape[1]

				# If we want to use relative positions for audio context, we can just offset
				# this sequence by the length of encodings_and_masks.
				__SCREAMING_SNAKE_CASE            = torch.broadcast_to(
				    torch.arange(lowerCAmelCase__							,  device=decoder_input_tokens.device)							,  (batch, seq_length)							,  )

				__SCREAMING_SNAKE_CASE            = self.position_encoding(lowerCAmelCase__)

				__SCREAMING_SNAKE_CASE            = self.continuous_inputs_projection(lowerCAmelCase__)
				inputs += position_encodings
				__SCREAMING_SNAKE_CASE            = self.dropout(lowerCAmelCase__)

				# decoder: No padding present.
				__SCREAMING_SNAKE_CASE            = torch.ones(
				    decoder_input_tokens.shape[:2]							,  device=decoder_input_tokens.device							,  dtype=inputs.dtype)

				# Translate encoding masks to encoder-decoder masks.
				__SCREAMING_SNAKE_CASE            = [(x, self.encoder_decoder_mask(lowerCAmelCase__							,  lowerCAmelCase__)) for x, y in encodings_and_masks]

				# cross attend style: concat encodings
				__SCREAMING_SNAKE_CASE            = torch.cat([x[0] for x in encodings_and_encdec_masks]							,  dim=1)
				__SCREAMING_SNAKE_CASE            = torch.cat([x[1] for x in encodings_and_encdec_masks]							,  dim=-1)

				for lyr in self.decoders:
						__SCREAMING_SNAKE_CASE            = lyr(
						    lowerCAmelCase__							,  conditioning_emb=lowerCAmelCase__							,  encoder_hidden_states=lowerCAmelCase__							,  encoder_attention_mask=lowerCAmelCase__							,  )[0]

				__SCREAMING_SNAKE_CASE            = self.decoder_norm(lowerCAmelCase__)
				__SCREAMING_SNAKE_CASE            = self.post_dropout(lowerCAmelCase__)

				__SCREAMING_SNAKE_CASE            = self.spec_out(lowerCAmelCase__)
				return spec_out



class 						SCREAMING_SNAKE_CASE_ (						nn.Module ):




		"""simple docstring"""





		def __init__(     self							,  lowerCAmelCase__							,  lowerCAmelCase__							,  lowerCAmelCase__							,  lowerCAmelCase__							,  lowerCAmelCase__							,  lowerCAmelCase__=1E-6):
				super().__init__()
				__SCREAMING_SNAKE_CASE            = nn.ModuleList()

				# cond self attention: layer 0
				self.layer.append(
				    TaLayerSelfAttentionCond(d_model=lowerCAmelCase__							,  d_kv=lowerCAmelCase__							,  num_heads=lowerCAmelCase__							,  dropout_rate=lowerCAmelCase__))

				# cross attention: layer 1
				self.layer.append(
				    TaLayerCrossAttention(
				        d_model=lowerCAmelCase__							,  d_kv=lowerCAmelCase__							,  num_heads=lowerCAmelCase__							,  dropout_rate=lowerCAmelCase__							,  layer_norm_epsilon=lowerCAmelCase__							,  ))

				# Film Cond MLP + dropout: last layer
				self.layer.append(
				    TaLayerFFCond(d_model=lowerCAmelCase__							,  d_ff=lowerCAmelCase__							,  dropout_rate=lowerCAmelCase__							,  layer_norm_epsilon=lowerCAmelCase__))




		def 	snake_case_     (     self							,  lowerCAmelCase__							,  lowerCAmelCase__=None							,  lowerCAmelCase__=None							,  lowerCAmelCase__=None							,  lowerCAmelCase__=None							,  lowerCAmelCase__=None							,  ):
				__SCREAMING_SNAKE_CASE            = self.layer[0](
				    lowerCAmelCase__							,  conditioning_emb=lowerCAmelCase__							,  attention_mask=lowerCAmelCase__							,  )

				if encoder_hidden_states is not None:
						__SCREAMING_SNAKE_CASE            = torch.where(encoder_attention_mask > 0							,  0							,  -1E10).to(
						    encoder_hidden_states.dtype)

						__SCREAMING_SNAKE_CASE            = self.layer[1](
						    lowerCAmelCase__							,  key_value_states=lowerCAmelCase__							,  attention_mask=lowerCAmelCase__							,  )

				# Apply Film Conditional Feed Forward layer
				__SCREAMING_SNAKE_CASE            = self.layer[-1](lowerCAmelCase__							,  lowerCAmelCase__)

				return (hidden_states,)



class 						SCREAMING_SNAKE_CASE_ (						nn.Module ):




		"""simple docstring"""





		def __init__(     self							,  lowerCAmelCase__							,  lowerCAmelCase__							,  lowerCAmelCase__							,  lowerCAmelCase__):
				super().__init__()
				__SCREAMING_SNAKE_CASE            = TaLayerNorm(lowerCAmelCase__)
				__SCREAMING_SNAKE_CASE            = TaFiLMLayer(in_features=d_model * 4							,  out_features=lowerCAmelCase__)
				__SCREAMING_SNAKE_CASE            = Attention(query_dim=lowerCAmelCase__							,  heads=lowerCAmelCase__							,  dim_head=lowerCAmelCase__							,  out_bias=lowerCAmelCase__							,  scale_qk=lowerCAmelCase__)
				__SCREAMING_SNAKE_CASE            = nn.Dropout(lowerCAmelCase__)




		def 	snake_case_     (     self							,  lowerCAmelCase__							,  lowerCAmelCase__=None							,  lowerCAmelCase__=None							,  ):
				# pre_self_attention_layer_norm
				__SCREAMING_SNAKE_CASE            = self.layer_norm(lowerCAmelCase__)

				if conditioning_emb is not None:
						__SCREAMING_SNAKE_CASE            = self.FiLMLayer(lowerCAmelCase__							,  lowerCAmelCase__)

				# Self-attention block
				__SCREAMING_SNAKE_CASE            = self.attention(lowerCAmelCase__)

				__SCREAMING_SNAKE_CASE            = hidden_states + self.dropout(lowerCAmelCase__)

				return hidden_states



class 						SCREAMING_SNAKE_CASE_ (						nn.Module ):




		"""simple docstring"""





		def __init__(     self							,  lowerCAmelCase__							,  lowerCAmelCase__							,  lowerCAmelCase__							,  lowerCAmelCase__							,  lowerCAmelCase__):
				super().__init__()
				__SCREAMING_SNAKE_CASE            = Attention(query_dim=lowerCAmelCase__							,  heads=lowerCAmelCase__							,  dim_head=lowerCAmelCase__							,  out_bias=lowerCAmelCase__							,  scale_qk=lowerCAmelCase__)
				__SCREAMING_SNAKE_CASE            = TaLayerNorm(lowerCAmelCase__							,  eps=lowerCAmelCase__)
				__SCREAMING_SNAKE_CASE            = nn.Dropout(lowerCAmelCase__)




		def 	snake_case_     (     self							,  lowerCAmelCase__							,  lowerCAmelCase__=None							,  lowerCAmelCase__=None							,  ):
				__SCREAMING_SNAKE_CASE            = self.layer_norm(lowerCAmelCase__)
				__SCREAMING_SNAKE_CASE            = self.attention(
				    lowerCAmelCase__							,  encoder_hidden_states=lowerCAmelCase__							,  attention_mask=attention_mask.squeeze(1)							,  )
				__SCREAMING_SNAKE_CASE            = hidden_states + self.dropout(lowerCAmelCase__)
				return layer_output



class 						SCREAMING_SNAKE_CASE_ (						nn.Module ):




		"""simple docstring"""





		def __init__(     self							,  lowerCAmelCase__							,  lowerCAmelCase__							,  lowerCAmelCase__							,  lowerCAmelCase__):
				super().__init__()
				__SCREAMING_SNAKE_CASE            = TaDenseGatedActDense(d_model=lowerCAmelCase__							,  d_ff=lowerCAmelCase__							,  dropout_rate=lowerCAmelCase__)
				__SCREAMING_SNAKE_CASE            = TaFiLMLayer(in_features=d_model * 4							,  out_features=lowerCAmelCase__)
				__SCREAMING_SNAKE_CASE            = TaLayerNorm(lowerCAmelCase__							,  eps=lowerCAmelCase__)
				__SCREAMING_SNAKE_CASE            = nn.Dropout(lowerCAmelCase__)




		def 	snake_case_     (     self							,  lowerCAmelCase__							,  lowerCAmelCase__=None):
				__SCREAMING_SNAKE_CASE            = self.layer_norm(lowerCAmelCase__)
				if conditioning_emb is not None:
						__SCREAMING_SNAKE_CASE            = self.film(lowerCAmelCase__							,  lowerCAmelCase__)

				__SCREAMING_SNAKE_CASE            = self.DenseReluDense(lowerCAmelCase__)
				__SCREAMING_SNAKE_CASE            = hidden_states + self.dropout(lowerCAmelCase__)
				return hidden_states



class 						SCREAMING_SNAKE_CASE_ (						nn.Module ):




		"""simple docstring"""





		def __init__(     self							,  lowerCAmelCase__							,  lowerCAmelCase__							,  lowerCAmelCase__):
				super().__init__()
				__SCREAMING_SNAKE_CASE            = nn.Linear(lowerCAmelCase__							,  lowerCAmelCase__							,  bias=lowerCAmelCase__)
				__SCREAMING_SNAKE_CASE            = nn.Linear(lowerCAmelCase__							,  lowerCAmelCase__							,  bias=lowerCAmelCase__)
				__SCREAMING_SNAKE_CASE            = nn.Linear(lowerCAmelCase__							,  lowerCAmelCase__							,  bias=lowerCAmelCase__)
				__SCREAMING_SNAKE_CASE            = nn.Dropout(lowerCAmelCase__)
				__SCREAMING_SNAKE_CASE            = NewGELUActivation()




		def 	snake_case_     (     self							,  lowerCAmelCase__):
				__SCREAMING_SNAKE_CASE            = self.act(self.wi_a(lowerCAmelCase__))
				__SCREAMING_SNAKE_CASE            = self.wi_a(lowerCAmelCase__)
				__SCREAMING_SNAKE_CASE            = hidden_gelu * hidden_linear
				__SCREAMING_SNAKE_CASE            = self.dropout(lowerCAmelCase__)

				__SCREAMING_SNAKE_CASE            = self.wo(lowerCAmelCase__)
				return hidden_states



class 						SCREAMING_SNAKE_CASE_ (						nn.Module ):




		"""simple docstring"""





		def __init__(     self							,  lowerCAmelCase__							,  lowerCAmelCase__=1E-6):
				super().__init__()
				__SCREAMING_SNAKE_CASE            = nn.Parameter(torch.ones(lowerCAmelCase__))
				__SCREAMING_SNAKE_CASE            = eps




		def 	snake_case_     (     self							,  lowerCAmelCase__):
				# T5 uses a layer_norm which only scales and doesn't shift, which is also known as Root Mean
				# Square Layer Normalization https://arxiv.org/abs/1910.07467 thus variance is calculated
				# w/o mean and there is no bias. Additionally we want to make sure that the accumulation for
				# half-precision inputs is done in fp32

				__SCREAMING_SNAKE_CASE            = hidden_states.to(torch.floataa).pow(2).mean(-1							,  keepdim=lowerCAmelCase__)
				__SCREAMING_SNAKE_CASE            = hidden_states * torch.rsqrt(variance + self.variance_epsilon)

				# convert into half-precision if necessary
				if self.weight.dtype in [torch.floataa, torch.bfloataa]:
						__SCREAMING_SNAKE_CASE            = hidden_states.to(self.weight.dtype)

				return self.weight * hidden_states



class 						SCREAMING_SNAKE_CASE_ (						nn.Module ):




		"""simple docstring"""





		def 	snake_case_     (     self							,  lowerCAmelCase__):
				return 0.5 * input * (1.0 + torch.tanh(math.sqrt(2.0 / math.pi) * (input + 0.04_47_15 * torch.pow(lowerCAmelCase__							,  3.0))))



class 						SCREAMING_SNAKE_CASE_ (						nn.Module ):




		"""simple docstring"""





		def __init__(     self							,  lowerCAmelCase__							,  lowerCAmelCase__):
				super().__init__()
				__SCREAMING_SNAKE_CASE            = nn.Linear(lowerCAmelCase__							,  out_features * 2							,  bias=lowerCAmelCase__)




		def 	snake_case_     (     self							,  lowerCAmelCase__							,  lowerCAmelCase__):
				__SCREAMING_SNAKE_CASE            = self.scale_bias(lowerCAmelCase__)
				__SCREAMING_SNAKE_CASE       ,__SCREAMING_SNAKE_CASE            = torch.chunk(lowerCAmelCase__							,  2							,  -1)
				__SCREAMING_SNAKE_CASE            = x * (1 + scale) + shift
				return x






"""simple docstring"""





from typing import Dict

import numpy as np

from ..utils import add_end_docstrings, is_tf_available, is_torch_available, logging
from .base import PIPELINE_INIT_ARGS, GenericTensor, Pipeline, PipelineException


if is_tf_available():
							import tensorflow as tf

							from ..tf_utils import stable_softmax


if is_torch_available():
							import torch


__magic_name__       =			logging.get_logger(__name__)
@add_end_docstrings(
    __a     ,				R'''
        top_k (`int`, defaults to 5):
            The number of predictions to return.
        targets (`str` or `List[str]`, *optional*):
            When passed, the model will limit the scores to the passed targets instead of looking up in the whole
            vocab. If the provided targets are not in the model vocab, they will be tokenized and the first resulting
            token will be used (with a warning, and that might be slower).

    '''     ,				)
class 						SCREAMING_SNAKE_CASE_ (						__a ):




		"""simple docstring"""





		def 	snake_case_     (     self							,  lowerCAmelCase__):
				if self.framework == "tf":
						__SCREAMING_SNAKE_CASE            = tf.where(input_ids == self.tokenizer.mask_token_id).numpy()
				elif self.framework == "pt":
						__SCREAMING_SNAKE_CASE            = torch.nonzero(input_ids == self.tokenizer.mask_token_id							,  as_tuple=lowerCAmelCase__)
				else:
						raise ValueError("""Unsupported framework""")
				return masked_index




		def 	snake_case_     (     self							,  lowerCAmelCase__):
				__SCREAMING_SNAKE_CASE            = self.get_masked_index(lowerCAmelCase__)
				__SCREAMING_SNAKE_CASE            = np.prod(masked_index.shape)
				if numel < 1:
						raise PipelineException(
						    """fill-mask"""							,  self.model.base_model_prefix							,  f"No mask_token ({self.tokenizer.mask_token}) found on the input"							,  )




		def 	snake_case_     (     self							,  lowerCAmelCase__):
				if isinstance(lowerCAmelCase__							,  lowerCAmelCase__):
						for model_input in model_inputs:
								self._ensure_exactly_one_mask_token(model_input["""input_ids"""][0])
				else:
						for input_ids in model_inputs["input_ids"]:
								self._ensure_exactly_one_mask_token(lowerCAmelCase__)




		def 	snake_case_     (     self							,  lowerCAmelCase__							,  lowerCAmelCase__=None							,  **lowerCAmelCase__):
				if return_tensors is None:
						__SCREAMING_SNAKE_CASE            = self.framework
				__SCREAMING_SNAKE_CASE            = self.tokenizer(lowerCAmelCase__							,  return_tensors=lowerCAmelCase__)
				self.ensure_exactly_one_mask_token(lowerCAmelCase__)
				return model_inputs




		def 	snake_case_     (     self							,  lowerCAmelCase__):
				__SCREAMING_SNAKE_CASE            = self.model(**lowerCAmelCase__)
				__SCREAMING_SNAKE_CASE            = model_inputs["""input_ids"""]
				return model_outputs




		def 	snake_case_     (     self							,  lowerCAmelCase__							,  lowerCAmelCase__=5							,  lowerCAmelCase__=None):
				# Cap top_k if there are targets
				if target_ids is not None and target_ids.shape[0] < top_k:
						__SCREAMING_SNAKE_CASE            = target_ids.shape[0]
				__SCREAMING_SNAKE_CASE            = model_outputs["""input_ids"""][0]
				__SCREAMING_SNAKE_CASE            = model_outputs["""logits"""]

				if self.framework == "tf":
						__SCREAMING_SNAKE_CASE            = tf.where(input_ids == self.tokenizer.mask_token_id).numpy()[:, 0]

						__SCREAMING_SNAKE_CASE            = outputs.numpy()

						__SCREAMING_SNAKE_CASE            = outputs[0, masked_index, :]
						__SCREAMING_SNAKE_CASE            = stable_softmax(lowerCAmelCase__							,  axis=-1)
						if target_ids is not None:
								__SCREAMING_SNAKE_CASE            = tf.gather_nd(tf.squeeze(lowerCAmelCase__							,  0)							,  target_ids.reshape(-1							,  1))
								__SCREAMING_SNAKE_CASE            = tf.expand_dims(lowerCAmelCase__							,  0)

						__SCREAMING_SNAKE_CASE            = tf.math.top_k(lowerCAmelCase__							,  k=lowerCAmelCase__)
						__SCREAMING_SNAKE_CASE       ,__SCREAMING_SNAKE_CASE            = topk.values.numpy(), topk.indices.numpy()
				else:
						__SCREAMING_SNAKE_CASE            = torch.nonzero(input_ids == self.tokenizer.mask_token_id							,  as_tuple=lowerCAmelCase__).squeeze(-1)
						# Fill mask pipeline supports only one ${mask_token} per sample

						__SCREAMING_SNAKE_CASE            = outputs[0, masked_index, :]
						__SCREAMING_SNAKE_CASE            = logits.softmax(dim=-1)
						if target_ids is not None:
								__SCREAMING_SNAKE_CASE            = probs[..., target_ids]

						__SCREAMING_SNAKE_CASE       ,__SCREAMING_SNAKE_CASE            = probs.topk(lowerCAmelCase__)

				__SCREAMING_SNAKE_CASE            = []
				__SCREAMING_SNAKE_CASE            = values.shape[0] == 1
				for i, (_values, _predictions) in enumerate(zip(values.tolist()							,  predictions.tolist())):
						__SCREAMING_SNAKE_CASE            = []
						for v, p in zip(_values							,  _predictions):
								# Copy is important since we're going to modify this array in place
								__SCREAMING_SNAKE_CASE            = input_ids.numpy().copy()
								if target_ids is not None:
										__SCREAMING_SNAKE_CASE            = target_ids[p].tolist()

								__SCREAMING_SNAKE_CASE            = p
								# Filter padding out:
								__SCREAMING_SNAKE_CASE            = tokens[np.where(tokens != self.tokenizer.pad_token_id)]
								# Originally we skip special tokens to give readable output.
								# For multi masks though, the other [MASK] would be removed otherwise
								# making the output look odd, so we add them back
								__SCREAMING_SNAKE_CASE            = self.tokenizer.decode(lowerCAmelCase__							,  skip_special_tokens=lowerCAmelCase__)
								__SCREAMING_SNAKE_CASE            = {"""score""": v, """token""": p, """token_str""": self.tokenizer.decode([p]), """sequence""": sequence}
								row.append(lowerCAmelCase__)
						result.append(lowerCAmelCase__)
				if single_mask:
						return result[0]
				return result




		def 	snake_case_     (     self							,  lowerCAmelCase__							,  lowerCAmelCase__=None):
				if isinstance(lowerCAmelCase__							,  lowerCAmelCase__):
						__SCREAMING_SNAKE_CASE            = [targets]
				try:
						__SCREAMING_SNAKE_CASE            = self.tokenizer.get_vocab()
				except Exception:
						__SCREAMING_SNAKE_CASE            = {}
				__SCREAMING_SNAKE_CASE            = []
				for target in targets:
						__SCREAMING_SNAKE_CASE            = vocab.get(lowerCAmelCase__							,  lowerCAmelCase__)
						if id_ is None:
								__SCREAMING_SNAKE_CASE            = self.tokenizer(
								    lowerCAmelCase__							,  add_special_tokens=lowerCAmelCase__							,  return_attention_mask=lowerCAmelCase__							,  return_token_type_ids=lowerCAmelCase__							,  max_length=1							,  truncation=lowerCAmelCase__							,  )["""input_ids"""]
								if len(lowerCAmelCase__) == 0:
										logger.warning(
										    f"The specified target token `{target}` does not exist in the model vocabulary. "
										    """We cannot replace it with anything meaningful, ignoring it""")
										continue
								__SCREAMING_SNAKE_CASE            = input_ids[0]
								# XXX: If users encounter this pass
								# it becomes pretty slow, so let's make sure
								# The warning enables them to fix the input to
								# get faster performance.
								logger.warning(
								    f"The specified target token `{target}` does not exist in the model vocabulary. "
								    f"Replacing with `{self.tokenizer.convert_ids_to_tokens(id_)}`.")
						target_ids.append(id_)
				__SCREAMING_SNAKE_CASE            = list(set(lowerCAmelCase__))
				if len(lowerCAmelCase__) == 0:
						raise ValueError("""At least one target must be provided when passed.""")
				__SCREAMING_SNAKE_CASE            = np.array(lowerCAmelCase__)
				return target_ids




		def 	snake_case_     (     self							,  lowerCAmelCase__=None							,  lowerCAmelCase__=None):
				__SCREAMING_SNAKE_CASE            = {}

				if targets is not None:
						__SCREAMING_SNAKE_CASE            = self.get_target_ids(lowerCAmelCase__							,  lowerCAmelCase__)
						__SCREAMING_SNAKE_CASE            = target_ids

				if top_k is not None:
						__SCREAMING_SNAKE_CASE            = top_k

				if self.tokenizer.mask_token_id is None:
						raise PipelineException(
						    """fill-mask"""							,  self.model.base_model_prefix							,  """The tokenizer does not define a `mask_token`.""")
				return {}, {}, postprocess_params




		def __call__(     self							,  lowerCAmelCase__							,  *lowerCAmelCase__							,  **lowerCAmelCase__):
				__SCREAMING_SNAKE_CASE            = super().__call__(lowerCAmelCase__							,  **lowerCAmelCase__)
				if isinstance(lowerCAmelCase__							,  lowerCAmelCase__) and len(lowerCAmelCase__) == 1:
						return outputs[0]
				return outputs




