


"""simple docstring"""







import os
import unittest

from transformers import RealmTokenizerFast
from transformers.models.bert.tokenization_bert import (
    VOCAB_FILES_NAMES,
    BasicTokenizer,
    WordpieceTokenizer,
    _is_control,
    _is_punctuation,
    _is_whitespace,
)
from transformers.models.realm.tokenization_realm import RealmTokenizer
from transformers.testing_utils import require_tokenizers, slow

from ...test_tokenization_common import TokenizerTesterMixin, filter_non_english
@require_tokenizers
class 				lowerCamelCase							(      __SCREAMING_SNAKE_CASE					,       unittest.TestCase			):


							"""simple docstring"""
							SCREAMING_SNAKE_CASE              =   RealmTokenizer
							SCREAMING_SNAKE_CASE              =   RealmTokenizerFast
							SCREAMING_SNAKE_CASE              =   True
							SCREAMING_SNAKE_CASE              =   True
							SCREAMING_SNAKE_CASE              =   filter_non_english






							def        lowerCAmelCase  (    self			:  List[str]					):
													super().setUp()

													UpperCAmelCase__												=     [
													    '''[UNK]''',
													    '''[CLS]''',
													    '''[SEP]''',
													    '''[PAD]''',
													    '''[MASK]''',
													    '''want''',
													    '''##want''',
													    '''##ed''',
													    '''wa''',
													    '''un''',
													    '''runn''',
													    '''##ing''',
													    ''',''',
													    '''low''',
													    '''lowest''',
													]
													UpperCAmelCase__												=     os.path.join(self.tmpdirname		,			VOCAB_FILES_NAMES['''vocab_file''']					)
													with open(self.vocab_file		,			'''w'''		,			encoding='''utf-8'''					) as vocab_writer:
																			vocab_writer.write(''''''.join([x + '''\n''' for x in vocab_tokens]					)					)






							def        lowerCAmelCase  (    self			:  Tuple		,			lowerCamelCase_			:  Any					):
													UpperCAmelCase__												=     '''UNwant\u00E9d,running'''
													UpperCAmelCase__												=     '''unwanted, running'''
													return input_text, output_text






							def        lowerCAmelCase  (    self			:  Optional[int]					):
													UpperCAmelCase__												=     self.tokenizer_class(self.vocab_file					)

													UpperCAmelCase__												=     tokenizer.tokenize('''UNwant\u00E9d,running'''					)
													self.assertListEqual(lowerCamelCase_		,			['''un''', '''##want''', '''##ed''', ''',''', '''runn''', '''##ing''']					)
													self.assertListEqual(tokenizer.convert_tokens_to_ids(lowerCamelCase_					)		,			[9, 6, 7, 12, 10, 11]					)






							def        lowerCAmelCase  (    self			:  List[str]					):
													if not self.test_rust_tokenizer:
																			return

													UpperCAmelCase__												=     self.get_tokenizer()
													UpperCAmelCase__												=     self.get_rust_tokenizer()

													UpperCAmelCase__												=     '''UNwant\u00E9d,running'''

													UpperCAmelCase__												=     tokenizer.tokenize(lowerCamelCase_					)
													UpperCAmelCase__												=     rust_tokenizer.tokenize(lowerCamelCase_					)
													self.assertListEqual(lowerCamelCase_		,			lowerCamelCase_					)

													UpperCAmelCase__												=     tokenizer.encode(lowerCamelCase_		,			add_special_tokens=lowerCamelCase_					)
													UpperCAmelCase__												=     rust_tokenizer.encode(lowerCamelCase_		,			add_special_tokens=lowerCamelCase_					)
													self.assertListEqual(lowerCamelCase_		,			lowerCamelCase_					)

													UpperCAmelCase__												=     self.get_rust_tokenizer()
													UpperCAmelCase__												=     tokenizer.encode(lowerCamelCase_					)
													UpperCAmelCase__												=     rust_tokenizer.encode(lowerCamelCase_					)
													self.assertListEqual(lowerCamelCase_		,			lowerCamelCase_					)

													# With lower casing
													UpperCAmelCase__												=     self.get_tokenizer(do_lower_case=lowerCamelCase_					)
													UpperCAmelCase__												=     self.get_rust_tokenizer(do_lower_case=lowerCamelCase_					)

													UpperCAmelCase__												=     '''UNwant\u00E9d,running'''

													UpperCAmelCase__												=     tokenizer.tokenize(lowerCamelCase_					)
													UpperCAmelCase__												=     rust_tokenizer.tokenize(lowerCamelCase_					)
													self.assertListEqual(lowerCamelCase_		,			lowerCamelCase_					)

													UpperCAmelCase__												=     tokenizer.encode(lowerCamelCase_		,			add_special_tokens=lowerCamelCase_					)
													UpperCAmelCase__												=     rust_tokenizer.encode(lowerCamelCase_		,			add_special_tokens=lowerCamelCase_					)
													self.assertListEqual(lowerCamelCase_		,			lowerCamelCase_					)

													UpperCAmelCase__												=     self.get_rust_tokenizer()
													UpperCAmelCase__												=     tokenizer.encode(lowerCamelCase_					)
													UpperCAmelCase__												=     rust_tokenizer.encode(lowerCamelCase_					)
													self.assertListEqual(lowerCamelCase_		,			lowerCamelCase_					)






							def        lowerCAmelCase  (    self			:  Union[str, Any]					):
													UpperCAmelCase__												=     BasicTokenizer()

													self.assertListEqual(tokenizer.tokenize('''ah\u535A\u63A8zz'''					)		,			['''ah''', '''\u535A''', '''\u63A8''', '''zz''']					)






							def        lowerCAmelCase  (    self			:  int					):
													UpperCAmelCase__												=     BasicTokenizer(do_lower_case=lowerCamelCase_					)

													self.assertListEqual(
													    tokenizer.tokenize(''' \tHeLLo!how  \n Are yoU?  '''					)		,			['''hello''', '''!''', '''how''', '''are''', '''you''', '''?''']					)
													self.assertListEqual(tokenizer.tokenize('''H\u00E9llo'''					)		,			['''hello''']					)






							def        lowerCAmelCase  (    self			:  Any					):
													UpperCAmelCase__												=     BasicTokenizer(do_lower_case=lowerCamelCase_		,			strip_accents=lowerCamelCase_					)

													self.assertListEqual(
													    tokenizer.tokenize(''' \tHäLLo!how  \n Are yoU?  '''					)		,			['''hällo''', '''!''', '''how''', '''are''', '''you''', '''?''']					)
													self.assertListEqual(tokenizer.tokenize('''H\u00E9llo'''					)		,			['''h\u00E9llo''']					)






							def        lowerCAmelCase  (    self			:  Any					):
													UpperCAmelCase__												=     BasicTokenizer(do_lower_case=lowerCamelCase_		,			strip_accents=lowerCamelCase_					)

													self.assertListEqual(
													    tokenizer.tokenize(''' \tHäLLo!how  \n Are yoU?  '''					)		,			['''hallo''', '''!''', '''how''', '''are''', '''you''', '''?''']					)
													self.assertListEqual(tokenizer.tokenize('''H\u00E9llo'''					)		,			['''hello''']					)






							def        lowerCAmelCase  (    self			:  Dict					):
													UpperCAmelCase__												=     BasicTokenizer(do_lower_case=lowerCamelCase_					)

													self.assertListEqual(
													    tokenizer.tokenize(''' \tHäLLo!how  \n Are yoU?  '''					)		,			['''hallo''', '''!''', '''how''', '''are''', '''you''', '''?''']					)
													self.assertListEqual(tokenizer.tokenize('''H\u00E9llo'''					)		,			['''hello''']					)






							def        lowerCAmelCase  (    self			:  str					):
													UpperCAmelCase__												=     BasicTokenizer(do_lower_case=lowerCamelCase_					)

													self.assertListEqual(
													    tokenizer.tokenize(''' \tHeLLo!how  \n Are yoU?  '''					)		,			['''HeLLo''', '''!''', '''how''', '''Are''', '''yoU''', '''?''']					)






							def        lowerCAmelCase  (    self			:  Any					):
													UpperCAmelCase__												=     BasicTokenizer(do_lower_case=lowerCamelCase_		,			strip_accents=lowerCamelCase_					)

													self.assertListEqual(
													    tokenizer.tokenize(''' \tHäLLo!how  \n Are yoU?  '''					)		,			['''HäLLo''', '''!''', '''how''', '''Are''', '''yoU''', '''?''']					)






							def        lowerCAmelCase  (    self			:  List[Any]					):
													UpperCAmelCase__												=     BasicTokenizer(do_lower_case=lowerCamelCase_		,			strip_accents=lowerCamelCase_					)

													self.assertListEqual(
													    tokenizer.tokenize(''' \tHäLLo!how  \n Are yoU?  '''					)		,			['''HaLLo''', '''!''', '''how''', '''Are''', '''yoU''', '''?''']					)






							def        lowerCAmelCase  (    self			:  List[str]					):
													UpperCAmelCase__												=     BasicTokenizer(do_lower_case=lowerCamelCase_		,			never_split=['''[UNK]''']					)

													self.assertListEqual(
													    tokenizer.tokenize(''' \tHeLLo!how  \n Are yoU? [UNK]'''					)		,			['''HeLLo''', '''!''', '''how''', '''Are''', '''yoU''', '''?''', '''[UNK]''']					)






							def        lowerCAmelCase  (    self			:  Optional[int]					):
													UpperCAmelCase__												=     ['''[UNK]''', '''[CLS]''', '''[SEP]''', '''want''', '''##want''', '''##ed''', '''wa''', '''un''', '''runn''', '''##ing''']

													UpperCAmelCase__												=     {}
													for i, token in enumerate(lowerCamelCase_					):
																			UpperCAmelCase__												=     i
													UpperCAmelCase__												=     WordpieceTokenizer(vocab=lowerCamelCase_		,			unk_token='''[UNK]'''					)

													self.assertListEqual(tokenizer.tokenize(''''''					)		,			[]					)

													self.assertListEqual(tokenizer.tokenize('''unwanted running'''					)		,			['''un''', '''##want''', '''##ed''', '''runn''', '''##ing''']					)

													self.assertListEqual(tokenizer.tokenize('''unwantedX running'''					)		,			['''[UNK]''', '''runn''', '''##ing''']					)






							def        lowerCAmelCase  (    self			:  List[Any]					):
													self.assertTrue(_is_whitespace(''' '''					)					)
													self.assertTrue(_is_whitespace('''\t'''					)					)
													self.assertTrue(_is_whitespace('''\r'''					)					)
													self.assertTrue(_is_whitespace('''\n'''					)					)
													self.assertTrue(_is_whitespace('''\u00A0'''					)					)

													self.assertFalse(_is_whitespace('''A'''					)					)
													self.assertFalse(_is_whitespace('''-'''					)					)






							def        lowerCAmelCase  (    self			:  Any					):
													self.assertTrue(_is_control('''\u0005'''					)					)

													self.assertFalse(_is_control('''A'''					)					)
													self.assertFalse(_is_control(''' '''					)					)
													self.assertFalse(_is_control('''\t'''					)					)
													self.assertFalse(_is_control('''\r'''					)					)






							def        lowerCAmelCase  (    self			:  Optional[Any]					):
													self.assertTrue(_is_punctuation('''-'''					)					)
													self.assertTrue(_is_punctuation('''$'''					)					)
													self.assertTrue(_is_punctuation('''`'''					)					)
													self.assertTrue(_is_punctuation('''.'''					)					)

													self.assertFalse(_is_punctuation('''A'''					)					)
													self.assertFalse(_is_punctuation(''' '''					)					)






							def        lowerCAmelCase  (    self			:  Optional[Any]					):
													UpperCAmelCase__												=     self.get_tokenizer()

													# Example taken from the issue https://github.com/huggingface/tokenizers/issues/340
													self.assertListEqual([tokenizer.tokenize(lowerCamelCase_					) for t in ['''Test''', '''\xad''', '''test''']]		,			[['''[UNK]'''], [], ['''[UNK]''']]					)

													if self.test_rust_tokenizer:
																			UpperCAmelCase__												=     self.get_rust_tokenizer()
																			self.assertListEqual(
																			    [rust_tokenizer.tokenize(lowerCamelCase_					) for t in ['''Test''', '''\xad''', '''test''']]		,			[['''[UNK]'''], [], ['''[UNK]''']]					)






							@slow
							def        lowerCAmelCase  (    self			:  Dict					):
													UpperCAmelCase__												=     self.tokenizer_class.from_pretrained('''bert-base-uncased'''					)

													UpperCAmelCase__												=     tokenizer.encode('''sequence builders'''		,			add_special_tokens=lowerCamelCase_					)
													UpperCAmelCase__												=     tokenizer.encode('''multi-sequence build'''		,			add_special_tokens=lowerCamelCase_					)

													UpperCAmelCase__												=     tokenizer.build_inputs_with_special_tokens(lowerCamelCase_					)
													UpperCAmelCase__												=     tokenizer.build_inputs_with_special_tokens(lowerCamelCase_		,			lowerCamelCase_					)

													assert encoded_sentence == [101] + text + [102]
													assert encoded_pair == [101] + text + [102] + text_a + [102]






							def        lowerCAmelCase  (    self			:  List[str]					):
													for tokenizer, pretrained_name, kwargs in self.tokenizers_list:
																			with self.subTest(f"""{tokenizer.__class__.__name__} ({pretrained_name})"""					):
																									UpperCAmelCase__												=     self.rust_tokenizer_class.from_pretrained(lowerCamelCase_		,			**lowerCamelCase_					)

																									UpperCAmelCase__												=     f"""A, naïve {tokenizer_r.mask_token} AllenNLP sentence."""
																									UpperCAmelCase__												=     tokenizer_r.encode_plus(
																									    lowerCamelCase_		,			return_attention_mask=lowerCamelCase_		,			return_token_type_ids=lowerCamelCase_		,			return_offsets_mapping=lowerCamelCase_		,			add_special_tokens=lowerCamelCase_		,			)

																									UpperCAmelCase__												=     tokenizer_r.do_lower_case if hasattr(lowerCamelCase_		,			'''do_lower_case'''					) else False
																									UpperCAmelCase__												=     (
																									    [
																									        ((0, 0), tokenizer_r.cls_token),
																									        ((0, 1), '''A'''),
																									        ((1, 2), ''','''),
																									        ((3, 5), '''na'''),
																									        ((5, 6), '''##ï'''),
																									        ((6, 8), '''##ve'''),
																									        ((9, 15), tokenizer_r.mask_token),
																									        ((16, 21), '''Allen'''),
																									        ((21, 23), '''##NL'''),
																									        ((23, 24), '''##P'''),
																									        ((25, 33), '''sentence'''),
																									        ((33, 34), '''.'''),
																									        ((0, 0), tokenizer_r.sep_token),
																									    ]
																									    if not do_lower_case
																									    else [
																									        ((0, 0), tokenizer_r.cls_token),
																									        ((0, 1), '''a'''),
																									        ((1, 2), ''','''),
																									        ((3, 8), '''naive'''),
																									        ((9, 15), tokenizer_r.mask_token),
																									        ((16, 21), '''allen'''),
																									        ((21, 23), '''##nl'''),
																									        ((23, 24), '''##p'''),
																									        ((25, 33), '''sentence'''),
																									        ((33, 34), '''.'''),
																									        ((0, 0), tokenizer_r.sep_token),
																									    ]
																									)

																									self.assertEqual(
																									    [e[1] for e in expected_results]		,			tokenizer_r.convert_ids_to_tokens(tokens['''input_ids''']					)					)
																									self.assertEqual([e[0] for e in expected_results]		,			tokens['''offset_mapping''']					)






							@slow
							def        lowerCAmelCase  (    self			:  Union[str, Any]					):
													for tokenizer, pretrained_name, kwargs in self.tokenizers_list:
																			with self.subTest(f"""{tokenizer.__class__.__name__} ({pretrained_name})"""					):
																									UpperCAmelCase__												=     self.rust_tokenizer_class.from_pretrained(lowerCamelCase_		,			**lowerCamelCase_					)
																									UpperCAmelCase__												=     self.tokenizer_class.from_pretrained(lowerCamelCase_		,			**lowerCamelCase_					)
																									UpperCAmelCase__												=     [['''Hello world!''', '''Nice to meet you!'''], ['''The cute cat.''', '''The adorable dog.''']]

																									UpperCAmelCase__												=     tokenizer_r.batch_encode_candidates(lowerCamelCase_		,			max_length=10		,			return_tensors='''np'''					)
																									UpperCAmelCase__												=     tokenizer_p.batch_encode_candidates(lowerCamelCase_		,			max_length=10		,			return_tensors='''np'''					)

																									UpperCAmelCase__												=     (2, 2, 10)

																									self.assertEqual(encoded_sentence_r['''input_ids'''].shape		,			lowerCamelCase_					)
																									self.assertEqual(encoded_sentence_r['''attention_mask'''].shape		,			lowerCamelCase_					)
																									self.assertEqual(encoded_sentence_r['''token_type_ids'''].shape		,			lowerCamelCase_					)

																									self.assertEqual(encoded_sentence_p['''input_ids'''].shape		,			lowerCamelCase_					)
																									self.assertEqual(encoded_sentence_p['''attention_mask'''].shape		,			lowerCamelCase_					)
																									self.assertEqual(encoded_sentence_p['''token_type_ids'''].shape		,			lowerCamelCase_					)



"""simple docstring"""







import inspect
from typing import Callable, List, Optional, Set, Tuple, Union

import torch
from packaging import version
from safetensors.torch import storage_ptr, storage_size
from torch import nn

from .utils import logging


__a      			= [nn.LayerNorm]

__a      			= logging.get_logger(__name__)

__a      			= version.parse(version.parse(torch.__version__).base_version)

__a      			= parsed_torch_version_base >= version.parse("2.0")
__a      			= parsed_torch_version_base >= version.parse("1.12")
__a      			= parsed_torch_version_base >= version.parse("1.11")
__a      			= parsed_torch_version_base < version.parse("1.11")






def        a__			(							_UpperCamelCase						,      _UpperCamelCase						,      _UpperCamelCase						,      _UpperCamelCase						,      self			):





						"""simple docstring"""

						from torch import _softmax_backward_data

						if is_torch_less_than_1_11:
												return _softmax_backward_data(_UpperCamelCase						,      _UpperCamelCase						,      parent.dim						,      self			)
						else:
												return _softmax_backward_data(_UpperCamelCase						,      _UpperCamelCase						,      parent.dim						,      self.dtype			)






def        a__			(							_UpperCamelCase						,      _UpperCamelCase						,      _UpperCamelCase = 0			):





						"""simple docstring"""

						UpperCAmelCase__												=     index.to(layer.weight.device			)
						UpperCAmelCase__												=     layer.weight.index_select(_UpperCamelCase						,      _UpperCamelCase			).clone().detach()
						if layer.bias is not None:
												if dim == 1:
																		UpperCAmelCase__												=     layer.bias.clone().detach()
												else:
																		UpperCAmelCase__												=     layer.bias[index].clone().detach()
						UpperCAmelCase__												=     list(layer.weight.size()			)
						UpperCAmelCase__												=     len(_UpperCamelCase			)
						UpperCAmelCase__												=     nn.Linear(new_size[1]						,      new_size[0]						,      bias=layer.bias is not None			).to(layer.weight.device			)
						UpperCAmelCase__												=     False
						new_layer.weight.copy_(W.contiguous()			)
						UpperCAmelCase__												=     True
						if layer.bias is not None:
												UpperCAmelCase__												=     False
												new_layer.bias.copy_(b.contiguous()			)
												UpperCAmelCase__												=     True
						return new_layer
class 				lowerCamelCase							(      nn.Module			):


							"""simple docstring"""






							def __init__(    self			:  str		,			lowerCamelCase_			:  Any		,			lowerCamelCase_			:  Dict					):
													super().__init__()
													UpperCAmelCase__												=     nf
													UpperCAmelCase__												=     nn.Parameter(torch.empty(lowerCamelCase_		,			lowerCamelCase_					)					)
													UpperCAmelCase__												=     nn.Parameter(torch.zeros(lowerCamelCase_					)					)
													nn.init.normal_(self.weight		,			std=0.02					)






							def        lowerCAmelCase  (    self			:  Any		,			lowerCamelCase_			:  Tuple					):
													UpperCAmelCase__												=     x.size()[:-1] + (self.nf,)
													UpperCAmelCase__												=     torch.addmm(self.bias		,			x.view(-1		,			x.size(-1					)					)		,			self.weight					)
													UpperCAmelCase__												=     x.view(lowerCamelCase_					)
													return x






def        a__			(							_UpperCamelCase						,      _UpperCamelCase						,      _UpperCamelCase = 1			):





						"""simple docstring"""

						UpperCAmelCase__												=     index.to(layer.weight.device			)
						UpperCAmelCase__												=     layer.weight.index_select(_UpperCamelCase						,      _UpperCamelCase			).clone().detach()
						if dim == 0:
												UpperCAmelCase__												=     layer.bias.clone().detach()
						else:
												UpperCAmelCase__												=     layer.bias[index].clone().detach()
						UpperCAmelCase__												=     list(layer.weight.size()			)
						UpperCAmelCase__												=     len(_UpperCamelCase			)
						UpperCAmelCase__												=     ConvaD(new_size[1]						,      new_size[0]			).to(layer.weight.device			)
						UpperCAmelCase__												=     False
						new_layer.weight.copy_(W.contiguous()			)
						UpperCAmelCase__												=     True
						UpperCAmelCase__												=     False
						new_layer.bias.copy_(b.contiguous()			)
						UpperCAmelCase__												=     True
						return new_layer






def        a__			(							_UpperCamelCase						,      _UpperCamelCase						,      _UpperCamelCase = None			):





						"""simple docstring"""

						if isinstance(_UpperCamelCase						,      nn.Linear			):
												return prune_linear_layer(_UpperCamelCase						,      _UpperCamelCase						,      dim=0 if dim is None else dim			)
						elif isinstance(_UpperCamelCase						,      _UpperCamelCase			):
												return prune_convad_layer(_UpperCamelCase						,      _UpperCamelCase						,      dim=1 if dim is None else dim			)
						else:
												raise ValueError(F"""Can't prune layer of class {layer.__class__}"""			)






def        a__			(							_UpperCamelCase						,      _UpperCamelCase						,      _UpperCamelCase						,      *_UpperCamelCase			):





						"""simple docstring"""

						assert len(_UpperCamelCase			) > 0, F"""{input_tensors} has to be a tuple/list of tensors"""

						# inspect.signature exist since python 3.5 and is a python method -> no problem with backward compatibility
						UpperCAmelCase__												=     len(inspect.signature(_UpperCamelCase			).parameters			)
						if num_args_in_forward_chunk_fn != len(_UpperCamelCase			):
												raise ValueError(
												    F"""forward_chunk_fn expects {num_args_in_forward_chunk_fn} arguments, but only {len(_UpperCamelCase			)} input """
												    '''tensors are given'''			)

						if chunk_size > 0:
												UpperCAmelCase__												=     input_tensors[0].shape[chunk_dim]
												for input_tensor in input_tensors:
																		if input_tensor.shape[chunk_dim] != tensor_shape:
																								raise ValueError(
																								    F"""All input tenors have to be of the same shape: {tensor_shape}, """
																								    F"""found shape {input_tensor.shape[chunk_dim]}"""			)

												if input_tensors[0].shape[chunk_dim] % chunk_size != 0:
																		raise ValueError(
																		    F"""The dimension to be chunked {input_tensors[0].shape[chunk_dim]} has to be a multiple of the chunk """
																		    F"""size {chunk_size}"""			)

												UpperCAmelCase__												=     input_tensors[0].shape[chunk_dim] // chunk_size

												# chunk input tensor into tuples
												UpperCAmelCase__												=     tuple(input_tensor.chunk(_UpperCamelCase						,      dim=_UpperCamelCase			) for input_tensor in input_tensors			)
												# apply forward fn to every tuple
												UpperCAmelCase__												=     tuple(forward_fn(*_UpperCamelCase			) for input_tensors_chunk in zip(*_UpperCamelCase			)			)
												# concatenate output at same dimension
												return torch.cat(_UpperCamelCase						,      dim=_UpperCamelCase			)

						return forward_fn(*_UpperCamelCase			)






def        a__			(							_UpperCamelCase						,      _UpperCamelCase						,      _UpperCamelCase						,      _UpperCamelCase			):





						"""simple docstring"""

						UpperCAmelCase__												=     torch.ones(_UpperCamelCase						,      _UpperCamelCase			)
						UpperCAmelCase__												=     set(_UpperCamelCase			) - already_pruned_heads  # Convert to set and remove already pruned heads
						for head in heads:
												# Compute how many pruned heads are before the head and move the index accordingly
												UpperCAmelCase__												=     head - sum(1 if h < head else 0 for h in already_pruned_heads			)
												UpperCAmelCase__												=     0
						UpperCAmelCase__												=     mask.view(-1			).contiguous().eq(1			)
						UpperCAmelCase__												=     torch.arange(len(_UpperCamelCase			)			)[mask].long()
						return heads, index






def        a__			(							*_UpperCamelCase						,      _UpperCamelCase = None			):





						"""simple docstring"""

						return torch.meshgrid(*_UpperCamelCase						,      indexing=_UpperCamelCase			)






def        a__			(							_UpperCamelCase			):





						"""simple docstring"""

						return tensor.device, storage_ptr(_UpperCamelCase			), storage_size(_UpperCamelCase			)