
from typing import Any, Dict, Optional

import torch
import torch.nn.functional as F
from torch import nn

from ..utils import maybe_allow_in_graph
from .activations import get_activation
from .attention_processor import Attention
from .embeddings import CombinedTimestepLabelEmbeddings

@maybe_allow_in_graph
class 							_UpperCamelCase					(       nn.Module	):






			'''simple docstring'''

			def __init__(							self			:							List[Any]    ,						snake_case_			:							int    ,						snake_case_			:							int    ,						snake_case_			:							int    ,						snake_case_			:							Optional[Any]=0.0    ,						snake_case_			:							Optional[int] = None    ,						snake_case_			:							str = "geglu"    ,						snake_case_			:							Optional[int] = None    ,						snake_case_			:							bool = False    ,						snake_case_			:							bool = False    ,						snake_case_			:							bool = False    ,						snake_case_			:							bool = False    ,						snake_case_			:							bool = True    ,						snake_case_			:							str = "layer_norm"    ,						snake_case_			:							bool = False    ,						):
							super().__init__()
							UpperCamelCase_:				int						=    only_cross_attention

							UpperCamelCase_:				Optional[Any]						=    (num_embeds_ada_norm is not None) and norm_type == """ada_norm_zero"""
							UpperCamelCase_:				Any						=    (num_embeds_ada_norm is not None) and norm_type == """ada_norm"""

							if norm_type in ("ada_norm", "ada_norm_zero") and num_embeds_ada_norm is None:
											raise ValueError(
											    f'''`norm_type` is set to {norm_type}, but `num_embeds_ada_norm` is not defined. Please make sure to'''
											    f''' define `num_embeds_ada_norm` if setting `norm_type` to {norm_type}.'''   )

							# Define 3 blocks. Each block has its own normalization layer.
							# 1. Self-Attn
							if self.use_ada_layer_norm:
											UpperCamelCase_:				Optional[Any]						=    AdaLayerNorm(snake_case_    ,						snake_case_   )
							elif self.use_ada_layer_norm_zero:
											UpperCamelCase_:				List[str]						=    AdaLayerNormZero(snake_case_    ,						snake_case_   )
							else:
											UpperCamelCase_:				List[str]						=    nn.LayerNorm(snake_case_    ,						elementwise_affine=snake_case_   )
							UpperCamelCase_:				Dict						=    Attention(
							    query_dim=snake_case_    ,						heads=snake_case_    ,						dim_head=snake_case_    ,						dropout=snake_case_    ,						bias=snake_case_    ,						cross_attention_dim=cross_attention_dim if only_cross_attention else None    ,						upcast_attention=snake_case_    ,						)

							# 2. Cross-Attn
							if cross_attention_dim is not None or double_self_attention:
											# We currently only use AdaLayerNormZero for self attention where there will only be one attention block.
											# I.e. the number of returned modulation chunks from AdaLayerZero would not make sense if returned during
											# the second cross attention block.
											UpperCamelCase_:				Any						=    (
											    AdaLayerNorm(snake_case_    ,						snake_case_   )
											    if self.use_ada_layer_norm
											    else nn.LayerNorm(snake_case_    ,						elementwise_affine=snake_case_   )
											)
											UpperCamelCase_:				Optional[Any]						=    Attention(
											    query_dim=snake_case_    ,						cross_attention_dim=cross_attention_dim if not double_self_attention else None    ,						heads=snake_case_    ,						dim_head=snake_case_    ,						dropout=snake_case_    ,						bias=snake_case_    ,						upcast_attention=snake_case_    ,						)  # is self-attn if encoder_hidden_states is none
							else:
											UpperCamelCase_:				int						=    None
											UpperCamelCase_:				List[str]						=    None

							# 3. Feed-forward
							UpperCamelCase_:				Union[str, Any]						=    nn.LayerNorm(snake_case_    ,						elementwise_affine=snake_case_   )
							UpperCamelCase_:				Union[str, Any]						=    FeedForward(snake_case_    ,						dropout=snake_case_    ,						activation_fn=snake_case_    ,						final_dropout=snake_case_   )

							# let chunk size default to None
							UpperCamelCase_:				Tuple						=    None
							UpperCamelCase_:				List[str]						=    0

			def    lowerCAmelCase__						(							self			:							Optional[Any]    ,						snake_case_			:							Optional[int]    ,						snake_case_			:							int   ):
							# Sets chunk feed-forward
							UpperCamelCase_:				Tuple						=    chunk_size
							UpperCamelCase_:				Optional[int]						=    dim




			def    lowerCAmelCase__						(							self			:							Tuple    ,						snake_case_			:							torch.FloatTensor    ,						snake_case_			:							Optional[torch.FloatTensor] = None    ,						snake_case_			:							Optional[torch.FloatTensor] = None    ,						snake_case_			:							Optional[torch.FloatTensor] = None    ,						snake_case_			:							Optional[torch.LongTensor] = None    ,						snake_case_			:							Dict[str, Any] = None    ,						snake_case_			:							Optional[torch.LongTensor] = None    ,						):
							# Notice that normalization is always applied before the real computation in the following blocks.
							# 1. Self-Attention
							if self.use_ada_layer_norm:
											UpperCamelCase_:				List[Any]						=    self.norma(snake_case_    ,						snake_case_   )
							elif self.use_ada_layer_norm_zero:
											UpperCamelCase_, UpperCamelCase_, UpperCamelCase_, UpperCamelCase_, UpperCamelCase_:				str						=    self.norma(
											    snake_case_    ,						snake_case_    ,						snake_case_    ,						hidden_dtype=hidden_states.dtype   )
							else:
											UpperCamelCase_:				str						=    self.norma(snake_case_   )

							UpperCamelCase_:				List[Any]						=    cross_attention_kwargs if cross_attention_kwargs is not None else {}

							UpperCamelCase_:				Dict						=    self.attna(
							    snake_case_    ,						encoder_hidden_states=encoder_hidden_states if self.only_cross_attention else None    ,						attention_mask=snake_case_    ,						**snake_case_    ,						)
							if self.use_ada_layer_norm_zero:
											UpperCamelCase_:				Any						=    gate_msa.unsqueeze(1   ) * attn_output
							UpperCamelCase_:				Optional[Any]						=    attn_output + hidden_states

							# 2. Cross-Attention
							if self.attna is not None:
											UpperCamelCase_:				int						=    (
											    self.norma(snake_case_    ,						snake_case_   ) if self.use_ada_layer_norm else self.norma(snake_case_   )
											)

											UpperCamelCase_:				List[Any]						=    self.attna(
											    snake_case_    ,						encoder_hidden_states=snake_case_    ,						attention_mask=snake_case_    ,						**snake_case_    ,						)
											UpperCamelCase_:				str						=    attn_output + hidden_states

							# 3. Feed-forward
							UpperCamelCase_:				List[str]						=    self.norma(snake_case_   )

							if self.use_ada_layer_norm_zero:
											UpperCamelCase_:				Tuple						=    norm_hidden_states * (1 + scale_mlp[:, None]) + shift_mlp[:, None]

							if self._chunk_size is not None:
											# "feed_forward_chunk_size" can be used to save memory
											if norm_hidden_states.shape[self._chunk_dim] % self._chunk_size != 0:
															raise ValueError(
															    f'''`hidden_states` dimension to be chunked: {norm_hidden_states.shape[self._chunk_dim]} has to be divisible by chunk size: {self._chunk_size}. Make sure to set an appropriate `chunk_size` when calling `unet.enable_forward_chunking`.'''   )

											UpperCamelCase_:				int						=    norm_hidden_states.shape[self._chunk_dim] // self._chunk_size
											UpperCamelCase_:				Tuple						=    torch.cat(
											    [self.ff(snake_case_   ) for hid_slice in norm_hidden_states.chunk(snake_case_    ,						dim=self._chunk_dim   )]    ,						dim=self._chunk_dim    ,						)
							else:
											UpperCamelCase_:				int						=    self.ff(snake_case_   )

							if self.use_ada_layer_norm_zero:
											UpperCamelCase_:				List[str]						=    gate_mlp.unsqueeze(1   ) * ff_output

							UpperCamelCase_:				int						=    ff_output + hidden_states

							return hidden_states




class 							_UpperCamelCase					(       nn.Module	):






			'''simple docstring'''

			def __init__(							self			:							Union[str, Any]    ,						snake_case_			:							int    ,						snake_case_			:							Optional[int] = None    ,						snake_case_			:							int = 4    ,						snake_case_			:							float = 0.0    ,						snake_case_			:							str = "geglu"    ,						snake_case_			:							bool = False    ,						):
							super().__init__()
							UpperCamelCase_:				Tuple						=    int(dim * mult   )
							UpperCamelCase_:				Optional[Any]						=    dim_out if dim_out is not None else dim

							if activation_fn == "gelu":
											UpperCamelCase_:				Optional[Any]						=    GELU(snake_case_    ,						snake_case_   )
							if activation_fn == "gelu-approximate":
											UpperCamelCase_:				List[str]						=    GELU(snake_case_    ,						snake_case_    ,						approximate="""tanh"""   )
							elif activation_fn == "geglu":
											UpperCamelCase_:				Union[str, Any]						=    GEGLU(snake_case_    ,						snake_case_   )
							elif activation_fn == "geglu-approximate":
											UpperCamelCase_:				Tuple						=    ApproximateGELU(snake_case_    ,						snake_case_   )

							UpperCamelCase_:				Optional[int]						=    nn.ModuleList([]   )
							# project in
							self.net.append(snake_case_   )
							# project dropout
							self.net.append(nn.Dropout(snake_case_   )   )
							# project out
							self.net.append(nn.Linear(snake_case_    ,						snake_case_   )   )
							# FF as used in Vision Transformer, MLP-Mixer, etc. have a final dropout
							if final_dropout:
											self.net.append(nn.Dropout(snake_case_   )   )




			def    lowerCAmelCase__						(							self			:							str    ,						snake_case_			:							int   ):
							for module in self.net:
											UpperCamelCase_:				Tuple						=    module(snake_case_   )
							return hidden_states




class 							_UpperCamelCase					(       nn.Module	):






			'''simple docstring'''

			def __init__(							self			:							Optional[Any]    ,						snake_case_			:							int    ,						snake_case_			:							int    ,						snake_case_			:							str = "none"   ):
							super().__init__()
							UpperCamelCase_:				List[Any]						=    nn.Linear(snake_case_    ,						snake_case_   )
							UpperCamelCase_:				Any						=    approximate

			def    lowerCAmelCase__						(							self			:							Optional[Any]    ,						snake_case_			:							Optional[int]   ):
							if gate.device.type != "mps":
											return F.gelu(snake_case_    ,						approximate=self.approximate   )
							# mps: gelu is not implemented for float16
							return F.gelu(gate.to(dtype=torch.floataa   )    ,						approximate=self.approximate   ).to(dtype=gate.dtype   )




			def    lowerCAmelCase__						(							self			:							Any    ,						snake_case_			:							Optional[int]   ):
							UpperCamelCase_:				Any						=    self.proj(snake_case_   )
							UpperCamelCase_:				Dict						=    self.gelu(snake_case_   )
							return hidden_states




class 							_UpperCamelCase					(       nn.Module	):






			'''simple docstring'''

			def __init__(							self			:							List[Any]    ,						snake_case_			:							int    ,						snake_case_			:							int   ):
							super().__init__()
							UpperCamelCase_:				Tuple						=    nn.Linear(snake_case_    ,						dim_out * 2   )

			def    lowerCAmelCase__						(							self			:							Optional[Any]    ,						snake_case_			:							str   ):
							if gate.device.type != "mps":
											return F.gelu(snake_case_   )
							# mps: gelu is not implemented for float16
							return F.gelu(gate.to(dtype=torch.floataa   )   ).to(dtype=gate.dtype   )




			def    lowerCAmelCase__						(							self			:							Optional[int]    ,						snake_case_			:							Dict   ):
							UpperCamelCase_, UpperCamelCase_:				Tuple						=    self.proj(snake_case_   ).chunk(2    ,						dim=-1   )
							return hidden_states * self.gelu(snake_case_   )




class 							_UpperCamelCase					(       nn.Module	):






			'''simple docstring'''

			def __init__(							self			:							Optional[Any]    ,						snake_case_			:							int    ,						snake_case_			:							int   ):
							super().__init__()
							UpperCamelCase_:				Tuple						=    nn.Linear(snake_case_    ,						snake_case_   )




			def    lowerCAmelCase__						(							self			:							Union[str, Any]    ,						snake_case_			:							Tuple   ):
							UpperCamelCase_:				str						=    self.proj(snake_case_   )
							return x * torch.sigmoid(1.702 * x   )




class 							_UpperCamelCase					(       nn.Module	):






			'''simple docstring'''

			def __init__(							self			:							List[str]    ,						snake_case_			:							Optional[Any]    ,						snake_case_			:							List[Any]   ):
							super().__init__()
							UpperCamelCase_:				Union[str, Any]						=    nn.Embedding(snake_case_    ,						snake_case_   )
							UpperCamelCase_:				str						=    nn.SiLU()
							UpperCamelCase_:				Union[str, Any]						=    nn.Linear(snake_case_    ,						embedding_dim * 2   )
							UpperCamelCase_:				Dict						=    nn.LayerNorm(snake_case_    ,						elementwise_affine=snake_case_   )




			def    lowerCAmelCase__						(							self			:							int    ,						snake_case_			:							Union[str, Any]    ,						snake_case_			:							Optional[int]   ):
							UpperCamelCase_:				int						=    self.linear(self.silu(self.emb(snake_case_   )   )   )
							UpperCamelCase_, UpperCamelCase_:				int						=    torch.chunk(snake_case_    ,						2   )
							UpperCamelCase_:				Optional[int]						=    self.norm(snake_case_   ) * (1 + scale) + shift
							return x




class 							_UpperCamelCase					(       nn.Module	):






			'''simple docstring'''

			def __init__(							self			:							List[Any]    ,						snake_case_			:							str    ,						snake_case_			:							Optional[int]   ):
							super().__init__()

							UpperCamelCase_:				Union[str, Any]						=    CombinedTimestepLabelEmbeddings(snake_case_    ,						snake_case_   )

							UpperCamelCase_:				Optional[Any]						=    nn.SiLU()
							UpperCamelCase_:				Union[str, Any]						=    nn.Linear(snake_case_    ,						6 * embedding_dim    ,						bias=snake_case_   )
							UpperCamelCase_:				Optional[int]						=    nn.LayerNorm(snake_case_    ,						elementwise_affine=snake_case_    ,						eps=1e-6   )




			def    lowerCAmelCase__						(							self			:							Any    ,						snake_case_			:							Tuple    ,						snake_case_			:							List[Any]    ,						snake_case_			:							Tuple    ,						snake_case_			:							Optional[int]=None   ):
							UpperCamelCase_:				Dict						=    self.linear(self.silu(self.emb(snake_case_    ,						snake_case_    ,						hidden_dtype=snake_case_   )   )   )
							UpperCamelCase_, UpperCamelCase_, UpperCamelCase_, UpperCamelCase_, UpperCamelCase_, UpperCamelCase_:				Any						=    emb.chunk(6    ,						dim=1   )
							UpperCamelCase_:				str						=    self.norm(snake_case_   ) * (1 + scale_msa[:, None]) + shift_msa[:, None]
							return x, gate_msa, shift_mlp, scale_mlp, gate_mlp




class 							_UpperCamelCase					(       nn.Module	):






			'''simple docstring'''

			def __init__(							self			:							Any    ,						snake_case_			:							int    ,						snake_case_			:							int    ,						snake_case_			:							int    ,						snake_case_			:							Optional[str] = None    ,						snake_case_			:							float = 1e-5   ):
							super().__init__()
							UpperCamelCase_:				Dict						=    num_groups
							UpperCamelCase_:				Any						=    eps

							if act_fn is None:
											UpperCamelCase_:				List[Any]						=    None
							else:
											UpperCamelCase_:				Any						=    get_activation(snake_case_   )

							UpperCamelCase_:				str						=    nn.Linear(snake_case_    ,						out_dim * 2   )




			def    lowerCAmelCase__						(							self			:							List[str]    ,						snake_case_			:							str    ,						snake_case_			:							str   ):
							if self.act:
											UpperCamelCase_:				Tuple						=    self.act(snake_case_   )
							UpperCamelCase_:				Optional[Any]						=    self.linear(snake_case_   )
							UpperCamelCase_:				Any						=    emb[:, :, None, None]
							UpperCamelCase_, UpperCamelCase_:				Optional[Any]						=    emb.chunk(2    ,						dim=1   )

							UpperCamelCase_:				int						=    F.group_norm(snake_case_    ,						self.num_groups    ,						eps=self.eps   )
							UpperCamelCase_:				Optional[Any]						=    x * (1 + scale) + shift
							return x








import subprocess
import sys

from transformers import BertConfig, BertModel, BertTokenizer, pipeline
from transformers.testing_utils import TestCasePlus, require_torch

class 							_UpperCamelCase					(       _A	):






			'''simple docstring'''

			@require_torch
			def    lowerCAmelCase__						(							self			:							List[str]   ):
							# this test is a bit tricky since TRANSFORMERS_OFFLINE can only be changed before
							# `transformers` is loaded, and it's too late for inside pytest - so we are changing it
							# while running an external program

							# python one-liner segments

							# this must be loaded before socket.socket is monkey-patched
							UpperCamelCase_:				Optional[Any]						=    """
from transformers import BertConfig, BertModel, BertTokenizer, pipeline
        """

							UpperCamelCase_:				List[Any]						=    """
mname = \"hf-internal-testing/tiny-random-bert\"
BertConfig.from_pretrained(mname)
BertModel.from_pretrained(mname)
BertTokenizer.from_pretrained(mname)
pipe = pipeline(task=\"fill-mask\", model=mname)
print(\"success\")
        """

							UpperCamelCase_:				Dict						=    """
import socket
def offline_socket(*args, **kwargs): raise RuntimeError(\"Offline mode is enabled, we shouldn't access internet\")
socket.socket = offline_socket
        """

							# Force fetching the files so that we can use the cache
							UpperCamelCase_:				int						=    """hf-internal-testing/tiny-random-bert"""
							BertConfig.from_pretrained(snake_case_   )
							BertModel.from_pretrained(snake_case_   )
							BertTokenizer.from_pretrained(snake_case_   )
							pipeline(task="""fill-mask"""    ,						model=snake_case_   )

							# baseline - just load from_pretrained with normal network
							UpperCamelCase_:				Tuple						=    [sys.executable, """-c""", """\n""".join([load, run, mock]   )]

							# should succeed
							UpperCamelCase_:				Optional[int]						=    self.get_env()
							# should succeed as TRANSFORMERS_OFFLINE=1 tells it to use local files
							UpperCamelCase_:				int						=    """1"""
							UpperCamelCase_:				Optional[Any]						=    subprocess.run(snake_case_    ,						env=snake_case_    ,						check=snake_case_    ,						capture_output=snake_case_   )
							self.assertEqual(result.returncode    ,						0    ,						result.stderr   )
							self.assertIn("""success"""    ,						result.stdout.decode()   )

			@require_torch
			def    lowerCAmelCase__						(							self			:							Any   ):
							# python one-liner segments
							# this must be loaded before socket.socket is monkey-patched
							UpperCamelCase_:				str						=    """
from transformers import BertConfig, BertModel, BertTokenizer, pipeline
        """

							UpperCamelCase_:				Any						=    """
mname = \"hf-internal-testing/tiny-random-bert\"
BertConfig.from_pretrained(mname)
BertModel.from_pretrained(mname)
BertTokenizer.from_pretrained(mname)
pipe = pipeline(task=\"fill-mask\", model=mname)
print(\"success\")
        """

							UpperCamelCase_:				Optional[int]						=    """
import socket
def offline_socket(*args, **kwargs): raise socket.error(\"Faking flaky internet\")
socket.socket = offline_socket
        """

							# Force fetching the files so that we can use the cache
							UpperCamelCase_:				Optional[int]						=    """hf-internal-testing/tiny-random-bert"""
							BertConfig.from_pretrained(snake_case_   )
							BertModel.from_pretrained(snake_case_   )
							BertTokenizer.from_pretrained(snake_case_   )
							pipeline(task="""fill-mask"""    ,						model=snake_case_   )

							# baseline - just load from_pretrained with normal network
							UpperCamelCase_:				Optional[int]						=    [sys.executable, """-c""", """\n""".join([load, run, mock]   )]

							# should succeed
							UpperCamelCase_:				List[str]						=    self.get_env()
							UpperCamelCase_:				List[Any]						=    subprocess.run(snake_case_    ,						env=snake_case_    ,						check=snake_case_    ,						capture_output=snake_case_   )
							self.assertEqual(result.returncode    ,						0    ,						result.stderr   )
							self.assertIn("""success"""    ,						result.stdout.decode()   )

			@require_torch
			def    lowerCAmelCase__						(							self			:							int   ):
							# this test is a bit tricky since TRANSFORMERS_OFFLINE can only be changed before
							# `transformers` is loaded, and it's too late for inside pytest - so we are changing it
							# while running an external program

							# python one-liner segments

							# this must be loaded before socket.socket is monkey-patched
							UpperCamelCase_:				Dict						=    """
from transformers import BertConfig, BertModel, BertTokenizer
        """

							UpperCamelCase_:				Optional[Any]						=    """
mname = \"hf-internal-testing/tiny-random-bert-sharded\"
BertConfig.from_pretrained(mname)
BertModel.from_pretrained(mname)
print(\"success\")
        """

							UpperCamelCase_:				Dict						=    """
import socket
def offline_socket(*args, **kwargs): raise ValueError(\"Offline mode is enabled\")
socket.socket = offline_socket
        """

							# baseline - just load from_pretrained with normal network
							UpperCamelCase_:				Union[str, Any]						=    [sys.executable, """-c""", """\n""".join([load, run]   )]

							# should succeed
							UpperCamelCase_:				Union[str, Any]						=    self.get_env()
							UpperCamelCase_:				List[Any]						=    subprocess.run(snake_case_    ,						env=snake_case_    ,						check=snake_case_    ,						capture_output=snake_case_   )
							self.assertEqual(result.returncode    ,						0    ,						result.stderr   )
							self.assertIn("""success"""    ,						result.stdout.decode()   )

							# next emulate no network
							UpperCamelCase_:				Optional[int]						=    [sys.executable, """-c""", """\n""".join([load, mock, run]   )]

							# Doesn't fail anymore since the model is in the cache due to other tests, so commenting this.
							# env["TRANSFORMERS_OFFLINE"] = "0"
							# result = subprocess.run(cmd, env=env, check=False, capture_output=True)
							# self.assertEqual(result.returncode, 1, result.stderr)

							# should succeed as TRANSFORMERS_OFFLINE=1 tells it to use local files
							UpperCamelCase_:				Union[str, Any]						=    """1"""
							UpperCamelCase_:				int						=    subprocess.run(snake_case_    ,						env=snake_case_    ,						check=snake_case_    ,						capture_output=snake_case_   )
							self.assertEqual(result.returncode    ,						0    ,						result.stderr   )
							self.assertIn("""success"""    ,						result.stdout.decode()   )

			@require_torch
			def    lowerCAmelCase__						(							self			:							List[str]   ):
							UpperCamelCase_:				Dict						=    """
from transformers import pipeline
        """
							UpperCamelCase_:				Union[str, Any]						=    """
mname = \"hf-internal-testing/tiny-random-bert\"
pipe = pipeline(model=mname)
        """

							UpperCamelCase_:				Dict						=    """
import socket
def offline_socket(*args, **kwargs): raise socket.error(\"Offline mode is enabled\")
socket.socket = offline_socket
        """
							UpperCamelCase_:				Optional[Any]						=    self.get_env()
							UpperCamelCase_:				int						=    """1"""
							UpperCamelCase_:				int						=    [sys.executable, """-c""", """\n""".join([load, mock, run]   )]
							UpperCamelCase_:				Any						=    subprocess.run(snake_case_    ,						env=snake_case_    ,						check=snake_case_    ,						capture_output=snake_case_   )
							self.assertEqual(result.returncode    ,						1    ,						result.stderr   )
							self.assertIn(
							    """You cannot infer task automatically within `pipeline` when using offline mode"""    ,						result.stderr.decode().replace("""\n"""    ,						""""""   )    ,						)




			@require_torch
			def    lowerCAmelCase__						(							self			:							Optional[int]   ):
							UpperCamelCase_:				str						=    """
from transformers import AutoModel
        """
							UpperCamelCase_:				Dict						=    """
mname = \"hf-internal-testing/test_dynamic_model\"
AutoModel.from_pretrained(mname, trust_remote_code=True)
print(\"success\")
        """

							# baseline - just load from_pretrained with normal network
							UpperCamelCase_:				Optional[int]						=    [sys.executable, """-c""", """\n""".join([load, run]   )]

							# should succeed
							UpperCamelCase_:				Optional[Any]						=    self.get_env()
							UpperCamelCase_:				int						=    subprocess.run(snake_case_    ,						env=snake_case_    ,						check=snake_case_    ,						capture_output=snake_case_   )
							self.assertEqual(result.returncode    ,						0    ,						result.stderr   )
							self.assertIn("""success"""    ,						result.stdout.decode()   )

							# should succeed as TRANSFORMERS_OFFLINE=1 tells it to use local files
							UpperCamelCase_:				Union[str, Any]						=    """1"""
							UpperCamelCase_:				List[str]						=    subprocess.run(snake_case_    ,						env=snake_case_    ,						check=snake_case_    ,						capture_output=snake_case_   )
							self.assertEqual(result.returncode    ,						0    ,						result.stderr   )
							self.assertIn("""success"""    ,						result.stdout.decode()   )






