id
stringlengths 3
8
| content
stringlengths 100
981k
|
|---|---|
1679215
|
import pytest
import pandas as pd
from matplotlib.figure import Figure
from shapely.geometry import Point, LineString
from plotly.graph_objs import Scattermapbox
from pam.plot.plans import build_person_df, build_cmap, build_person_travel_geodataframe, build_rgb_travel_cmap, \
plot_travel_plans
from pam.plot.stats import extract_activity_log, extract_leg_log, time_binner, plot_activity_times, plot_leg_times, \
plot_population_comparisons, calculate_leg_duration_by_mode
from .fixtures import person_heh, Steve, Hilda, instantiate_household_with
from pam.core import Household, Population
from copy import deepcopy
from pam.policy import policies
from tests.test_utils import cyclist, pt_person
def test_build_person_dataframe(person_heh):
df = build_person_df(person_heh)
assert len(df) == 5
assert list(df.act) == ['Home', 'Travel', 'Education', 'Travel', 'Home']
def test_build_cmap_dict():
df = pd.DataFrame(
[
{'act': 'Home', 'dur': None},
{'act': 'Travel', 'dur': None},
{'act': 'Work', 'dur': None},
{'act': 'Travel', 'dur': None},
{'act': 'Home', 'dur': None},
]
)
cmap = build_cmap(df)
assert isinstance(cmap, dict)
assert set(list(cmap)) == set(['Home', 'Work', 'Travel'])
def test_build_rgb_travel_cmap(Steve):
for leg in Steve.legs:
leg.start_location.loc = Point(1, 2)
leg.end_location.loc = Point(2, 3)
gdf = build_person_travel_geodataframe(Steve)
cmap = build_rgb_travel_cmap(gdf, colour_by='mode')
assert cmap == {'car': (255, 237, 111), 'walk': (204, 235, 197)}
def test_build_activity_log(person_heh):
population = Population()
for i in range(5):
hh = Household(i)
hh.add(person_heh)
population.add(hh)
log = extract_activity_log(population)
assert len(log) == 15
assert list(log.columns) == ['act', 'start', 'end', 'duration']
def test_build_leg_log(person_heh):
population = Population()
for i in range(5):
hh = Household(i)
hh.add(person_heh)
population.add(hh)
log = extract_leg_log(population)
assert len(log) == 10
assert list(log.columns) == ['mode', 'start', 'end', 'duration']
def test_time_binner(person_heh):
population = Population()
for i in range(5):
hh = Household(i)
hh.add(person_heh)
population.add(hh)
log = extract_activity_log(population)
binned = time_binner(log)
assert len(binned) == 96
for h in ['start', 'end', 'duration']:
assert binned[h].sum() == 3
def test_plot_act_time_bins(Steve, Hilda):
population = Population()
for i, person in enumerate([Steve, Hilda]):
hh = Household(i)
hh.add(person)
population.add(hh)
fig = plot_activity_times(population)
assert isinstance(fig, Figure)
def test_plot_leg_time_bins(Steve, Hilda):
population = Population()
for i, person in enumerate([Steve, Hilda]):
hh = Household(i)
hh.add(person)
population.add(hh)
fig = plot_leg_times(population)
assert isinstance(fig, Figure)
def test_plot_population_comparisons(Steve, Hilda):
population_1 = Population()
for i, person in enumerate([Steve, Hilda]):
hh = Household(i)
hh.add(person)
population_1.add(hh)
population_1.name = 'base'
population_2 = deepcopy(population_1)
population_2.name = 'work_removed'
policy_remove_work = policies.RemovePersonActivities(
activities=['work'],
probability=1
)
policies.apply_policies(population_2, [policy_remove_work])
list_of_populations = [population_1, population_2]
outputs = plot_population_comparisons(list_of_populations, 'home')
legs = outputs[2]
activities = outputs[3]
check = calculate_leg_duration_by_mode(population_2)
assert isinstance(outputs[0], Figure)
assert isinstance(outputs[1], Figure)
assert legs.loc['work_removed', 'walk'] == check.loc[check['leg mode'] == 'walk', 'duration_hours'].iloc[0]
def test_plot_travel_plans(cyclist):
fig = cyclist.plot_travel_plotly(mapbox_access_token='token')
assert len(fig.data) == 1
assert isinstance(fig.data[0], Scattermapbox)
assert fig.data[0].name == 'bike'
def test_plot_travel_plans_coloured_by_purp(pt_person):
fig = pt_person.plot_travel_plotly(colour_by='pid', mapbox_access_token='token')
assert len(fig.data) == 1
assert isinstance(fig.data[0], Scattermapbox)
assert fig.data[0].name == 'census_1'
def test_plot_travel_plans_grouped_by_legs(pt_person):
fig = pt_person.plot_travel_plotly(groupby=['seq'], mapbox_access_token='token')
for dat in fig.data:
assert isinstance(dat, Scattermapbox)
assert [dat.name for dat in fig.data] == ["('pt', 3)", "('pt', 5)", "('pt', 7)", "('transit_walk', 1)",
"('transit_walk', 2)", "('transit_walk', 4)", "('transit_walk', 6)",
"('transit_walk', 8)"]
def test_plot_travel_plans_for_household(cyclist, pt_person):
hhld = instantiate_household_with([cyclist, pt_person])
fig = hhld.plot_travel_plotly(mapbox_access_token='token')
assert len(fig.data) == 3
assert [dat.name for dat in fig.data] == ['bike', 'pt', 'transit_walk']
|
1679240
|
from setuptools import setup, find_packages
with open('README.md', 'r') as fh:
long_desc = fh.read()
setup(
name='pybbn',
version='3.2.1',
author='<NAME>',
author_email='<EMAIL>',
packages=find_packages(exclude=('*.tests', '*.tests.*', 'tests.*', 'tests')),
description='Learning and Inference in Bayesian Belief Networks',
long_description=long_desc,
long_description_content_type='text/markdown',
url='https://github.com/vangj/py-bbn',
keywords=' '.join(['bayesian', 'belief', 'network', 'exact', 'approximate', 'inference', 'junction', 'tree',
'algorithm', 'pptc', 'dag', 'gibbs', 'sampling', 'multivariate', 'conditional', 'gaussian',
'linear', 'causal', 'causality', 'structure', 'parameter', 'causal', 'causality']),
install_requires=['numpy', 'scipy', 'networkx', 'pandas'],
classifiers=[
'Programming Language :: Python :: 3',
'License :: OSI Approved :: Apache Software License',
'Operating System :: OS Independent',
'Topic :: Scientific/Engineering :: Artificial Intelligence',
'Intended Audience :: Developers',
'Intended Audience :: Science/Research',
'Development Status :: 5 - Production/Stable'
],
include_package_data=True,
test_suite='nose.collector'
)
|
1679243
|
import os
import numpy as np
import json
import random
import math
import argparse
import params
import torch
import time
import torch.utils.data as data
from data_utils import *
def worker_init(dataset, idx):
print ('hello world')
#dataset.file_list = [dataset.file_list[idx]]
l = len(dataset.file_list)
per = l // dataset.args.num_workers + 1
dataset.file_list = dataset.file_list[per*idx:min(l, per*(idx+1))]
print (dataset.file_list)
def mycollate(batch):
goal_tokens = [b[0] for b in batch]
goal_trees = [b[1] for b in batch]
return goal_tokens, goal_trees, torch.Tensor([b[2] for b in batch])
# [tensor of strings] in b
# [s*4] in b
# [str] in b* (1+neg)
# [s*4] in b* (1+neg)
class MetaMath(data.Dataset):
def __init__(self, args, split=None):
self.args = args
self.split = split if split is not None else args.split
if self.args.partial_lm:
if self.split == 'train':
self.file_list = list(range(4,20))
elif self.split == 'valid':
self.file_list = [0,1]
else:
self.file_list = [2,3]
self.file_list = [str(i) for i in self.file_list]
self.lm = build_language_model(self.args.num_props, new=self.args.gen_lm, _all=False)
self.config = get_config(self.lm)
self.steps = []
for fn in self.file_list:
with open(os.path.join(self.args.data_path+fn), 'rb') as f:
data = pickle.load(f)
for i,_pd in enumerate(data):
for tree in _pd.correct:
_to, _tr = encode_payout_step(tree, _pd.hyps, self.lm, self.config)
self.steps.append((_to, _tr, 1))
for tree in _pd.wrong:
_to, _tr = encode_payout_step(tree, _pd.hyps, self.lm, self.config)
self.steps.append((_to, _tr, 0))
print ('load %d payout steps' % (len(self.steps)))
self.idxes = list(range(len(self.steps)))
if not self.args.evaluate:
random.shuffle(self.idxes)
self.cnt = 0
self.length = len(self.idxes)
self.cur_epoch = 0
return
self.lm = load_language_model(_all=False, new=args.gen_lm, iset=args.iset)
self.config = get_config(self.lm)
if self.split == 'train':
self.file_list = list(range(4,20))
elif self.split == 'valid':
self.file_list = [0,1]
else:
self.file_list = [2,3]
self.file_list = [str(i) for i in self.file_list]
self.steps = []
name = self.args.data_path.split('/')[-2]
for fn in self.file_list:
with open(os.path.join(self.args.data_path+fn), 'rb') as f:
data = pickle.load(f)
for i,_pd in enumerate(data):
for tree in _pd.correct:
_to, _tr = encode_payout_step(tree, _pd.hyps, self.lm, self.config)
self.steps.append((_to, _tr, 1))
for tree in _pd.wrong:
_to, _tr = encode_payout_step(tree, _pd.hyps, self.lm, self.config)
self.steps.append((_to, _tr, 0))
self.idxes = list(range(len(self.steps)))
print ('load %d payout steps' % (len(self.steps)))
#self.file_list = [s for s in os.listdir(os.path.join(args.data_path, self.split))
# if s[-1] == 't']
self.cnt = 0
self.cur_file = 0
self.cur_epoch = 0
#self.steps = None
#self.inputs = None
#self.props = None
self.length = len(self.idxes)
if not self.args.evaluate:
random.shuffle(self.idxes)
#random.shuffle(self.file_list)
def load_steps(self, fn=None):
if self.args.partial_lm:
if not self.args.evaluate:
random.shuffle(self.idxes)
self.cnt = 0
self.cur_epoch += 1
return
if fn is None:
if self.cur_file == len(self.file_list):
self.cur_file = 0
self.cur_epoch += 1
fn = self.file_list[self.cur_file]
self.cur_file += 1
self.cnt = 0
print ('load from', fn)
with open(os.path.join(self.args.data_path, fn), 'rb') as f:
self.steps = pickle.load(f)
self.idxes = list(range(len(self.steps)))
if not self.args.evaluate:
random.shuffle(self.idxes)
def __getitem__(self, idx):
if self.steps is None or self.cnt == len(self.steps):
#if self.steps is None and not self.args.evaluate:
# random.shuffle(self.file_list)
#self.load_steps()
self.cnt = 0
self.cur_epoch += 1
idx = self.idxes[self.cnt]#idx % len(self.steps)
self.cnt += 1
tokens = [self.config.encode[i] for i in self.steps[idx][0]]
goal_tokens = torch.Tensor(tokens).long().to(self.args.device)
goal_tree = torch.Tensor(self.steps[idx][1]).to(self.args.device)
#print (self.cnt)
return goal_tokens, goal_tree, self.steps[idx][2]
def __len__(self):
return self.length
if __name__ == "__main__":
#parser = argparse.ArgumentParser(description='loader')
#parser.add_argument('--data-path', type=str, default='../data/')
#parser.add_argument('--split', type=str, default='train')
#parser.add_argument('--negative-samples', type=int, default=4)
#parser.add_argument('--num_workers')
#args = parser.parse_args()
args = params.get_args()
args.device = torch.device("cuda:0" if torch.cuda.is_available() else "cpu")
loader = torch.utils.data.DataLoader(
MetaMath(args), collate_fn=mycollate,
batch_size=10, shuffle=False, num_workers=0)#args.num_workers)
t = time.time()
for i in range(100):
data = next(iter(loader))
print ((time.time()-t)/(i+1))
print (data)
#print (data)
|
1679264
|
from magma import wire, compile, EndCircuit
from loam.boards.icestick import IceStick
from mantle.lattice.ice40.PLB import SB_DFF
icestick = IceStick()
icestick.Clock.on()
icestick.J1[0].rename('D').input().on()
icestick.J3[0].rename('Q').output().on()
main = icestick.main()
dff = SB_DFF()
wire(main.D, dff.D)
wire(dff.Q, main.Q)
EndCircuit()
|
1679287
|
from django.utils.translation import ugettext_lazy as _
from rest_framework import serializers
from mayan.apps.rest_api.serializer_mixins import CreateOnlyFieldSerializerMixin
from mayan.apps.user_management.serializers import UserSerializer
from ..models.favorite_document_models import FavoriteDocument
from .document_serializers import DocumentSerializer
class FavoriteDocumentSerializer(
CreateOnlyFieldSerializerMixin, serializers.HyperlinkedModelSerializer
):
document = DocumentSerializer(read_only=True)
document_id = serializers.IntegerField(
help_text=_('Document ID for the new favorite document.'),
write_only=True
)
user = UserSerializer(read_only=True)
class Meta:
extra_kwargs = {
'url': {
'lookup_url_kwarg': 'favorite_document_id',
'view_name': 'rest_api:favoritedocument-detail'
},
}
fields = (
'document', 'document_id', 'datetime_added', 'id', 'user', 'url'
)
model = FavoriteDocument
read_only_fields = (
'document', 'datetime_added', 'id', 'user', 'url'
)
|
1679374
|
import demistomock as demisto
from CommonServerPython import *
from CommonServerUserPython import *
''' IMPORTS '''
from requests import Session
from zeep import Client, Settings
from zeep.transports import Transport
from requests.auth import AuthBase, HTTPBasicAuth
from zeep import helpers
from zeep.cache import SqliteCache
from datetime import datetime
from typing import Dict, Tuple, Any
from dateutil.parser import parse
import urllib3
import uuid
import tempfile
import os
import shutil
# Disable insecure warnings
urllib3.disable_warnings()
def get_cache_path():
path = tempfile.gettempdir() + "/zeepcache"
try:
os.makedirs(path)
except OSError:
if os.path.isdir(path):
pass
else:
raise
db_path = os.path.join(path, "cache.db")
try:
if not os.path.isfile(db_path):
static_init_db = os.getenv('ZEEP_STATIC_CACHE_DB', '/zeep/static/cache.db')
if os.path.isfile(static_init_db):
demisto.debug(f'copying static init db: {static_init_db} to: {db_path}')
shutil.copyfile(static_init_db, db_path)
except Exception as ex:
# non fatal
demisto.error(f'Failed copying static init db to: {db_path}. Error: {ex}')
return db_path
class SymantecAuth(AuthBase):
def __init__(self, user, password, host):
self.basic = HTTPBasicAuth(user, password)
self.host = host
def __call__(self, r):
if r.url.startswith(self.host):
return self.basic(r)
else:
return r
''' HELPER FUNCTIONS '''
def get_data_owner(data_owner: Any) -> dict:
"""
parses the data owner object
:param data_owner: the data owner object, can be of any type
:return: the parsed object
"""
if data_owner and isinstance(data_owner, dict):
return {'Name': data_owner.get('name'), 'Email': data_owner.get('email')}
if data_owner and not isinstance(data_owner, dict):
LOG(f"A data owner was found in the incident, but did not match the expected format.\n "
f"Found: {str(data_owner)}")
return {}
def get_incident_binaries(client: Client, incident_id: str, include_original_message: bool = True,
include_all_components: bool = True) -> Tuple[str, dict, list, dict]:
"""
This function get's the binaries of a specific incident with the id incident_id
It generates the human readable, entry context & raw response. It also generates the binary files.
:param client: The client
:param incident_id: The ID of the incident
:param include_original_message: Indicates whether the Web Service should include the original message
in the response document.
:param include_all_components: Indicates whether the Web Service should include all message components
(for example, headers and file attachments) in the response document.
:return: The human readable, entry context, file entries & raw response
"""
raw_incident_binaries = client.service.incidentBinaries(
incidentId=incident_id,
includeOriginalMessage=include_original_message,
includeAllComponents=include_all_components,
)
human_readable: str
entry_context: dict = {}
raw_response: dict = {}
file_entries: list = []
if raw_incident_binaries:
serialized_incident_binaries: dict = helpers.serialize_object(raw_incident_binaries)
raw_response = json.loads(json.dumps(serialized_incident_binaries, default=bytes_to_string))
raw_components = serialized_incident_binaries.get('Component')
components: list = parse_component(raw_components) # type: ignore[arg-type]
incident_binaries: dict = {
'ID': serialized_incident_binaries.get('incidentId'),
'OriginalMessage': serialized_incident_binaries.get('originalMessage'),
'Component(val.ID && val.ID === obj.ID)': components,
'LongID': serialized_incident_binaries.get('incidentLongId')
}
raw_headers: list = ['ID', 'OriginalMessage', 'LongID']
headers: list = ['ID', 'Original Message', 'Long ID']
outputs: dict = {}
for raw_header in raw_headers:
outputs[headers[raw_headers.index(raw_header)]] = incident_binaries.get(raw_header)
human_readable = tableToMarkdown(f'Symantec DLP incident {incident_id} binaries', outputs,
headers=headers, removeNull=True)
for raw_component in raw_components: # type: ignore[union-attr]
filename = raw_component.get('name')
data = raw_component.get('content')
if isinstance(data, (str, bytes)):
file_entries.append(fileResult(filename=filename, data=data))
entry_context = {'SymantecDLP.Incident(val.ID && val.ID === obj.ID)': incident_binaries}
else:
human_readable = 'No incident found.'
return human_readable, entry_context, file_entries, raw_response
def parse_text(raw_text_list: list) -> list:
"""
Return the parsed text list
:param raw_text_list: the raw text list
:return: the parsed text list
"""
text_list: list = []
for raw_text in raw_text_list:
text: dict = {
'Data': raw_text.get('_value_1'),
'Type': raw_text.get('type'),
'RuleID': raw_text.get('ruleId'),
'RuleName': raw_text.get('ruleName')
}
text_list.append({key: val for key, val in text.items() if val})
return text_list
def parse_violation_segment(raw_violation_segment_list: list) -> list:
"""
Return the parsed violation segment list
:param raw_violation_segment_list: the raw violating segment list
:return: the parsed violation segment list
"""
violation_segment_list: list = []
for raw_violation_segment in raw_violation_segment_list:
violation_segment: dict = {
'DocumentViolation': raw_violation_segment.get('documentViolation'),
'FileSizeViolation': raw_violation_segment.get('fileSizeViolation'),
'Text': parse_text(raw_violation_segment.get('text', []))
}
violation_segment_list.append({key: val for key, val in violation_segment.items() if val})
return violation_segment_list
def parse_violating_component(raw_violating_component_list: list) -> list:
"""
Return the parsed violating component list
:param raw_violating_component_list: the raw violating component list
:return: the parsed violating component list
"""
violating_component_list: list = []
for raw_violating_component in raw_violating_component_list:
violating_component_type: dict = raw_violating_component.get('violatingComponentType', {})
violating_component: dict = {
'Name': raw_violating_component.get('name'),
'DocumentFormat': raw_violating_component.get('documentFormat'),
'Type': violating_component_type.get('_value_1'),
'TypeID': violating_component_type.get('id'),
'ViolatingCount': raw_violating_component.get('violationCount'),
'ViolationSegment': parse_violation_segment(raw_violating_component.get('violatingSegment', []))
}
violating_component_list.append({key: val for key, val in violating_component.items() if val})
return violating_component_list
def parse_violated_policy_rule(raw_violated_policy_rule_list: list) -> list:
"""
Parses a list of rules to context paths
:param raw_violated_policy_rule_list: the raw rules list
:return: the parsed rules list
"""
violated_policy_rule_list: list = []
for raw_violated_policy_rule in raw_violated_policy_rule_list:
violated_policy_rule: dict = {
'Name': raw_violated_policy_rule.get('ruleName'),
'ID': raw_violated_policy_rule.get('ID')
}
violated_policy_rule_list.append({key: val for key, val in violated_policy_rule.items() if val})
return violated_policy_rule_list
def parse_other_violated_policy(raw_other_violated_policy_list: list) -> list:
"""
Parses a list of policies to context paths
:param raw_other_violated_policy_list: the raw policies list
:return: the parsed policies list
"""
other_violated_policy_list: list = []
for raw_other_violated_policy in raw_other_violated_policy_list:
other_violated_policy: dict = {
'Name': raw_other_violated_policy.get('name'),
'Version': raw_other_violated_policy.get('version'),
'Label': raw_other_violated_policy.get('label'),
'ID': raw_other_violated_policy.get('policyId')
}
other_violated_policy_list.append({key: val for key, val in other_violated_policy.items() if val})
return other_violated_policy_list
def get_all_group_custom_attributes(group: dict) -> list:
"""
Returns a list of all the custom attributes in the group
:param group: the group
:return: the list of all custom attributes
"""
custom_attributes_list: list = []
for raw_custom_attribute in group.get('customAttribute', []):
custom_attribute: dict = {'Name': raw_custom_attribute.get('name')}
custom_attribute_value = raw_custom_attribute.get('value')
if custom_attribute_value:
custom_attribute['Value'] = custom_attribute_value
custom_attributes_list.append(custom_attribute)
return custom_attributes_list
def parse_custom_attribute(custom_attribute_group_list: list, args: dict) -> list:
"""
Returns a list of all custom attributes chosen by the user.
There are four options to choose from: all, none, specific attributes, custom attributes group name.
The choosing flag is given in demisto.args value in the field custom_attributes.
If the user has chosen "all" then the function will return all custom attributes possible (from all groups).
If the user has chosen "none" then the function won't return any custom attributes.
If the user has chosen "specific attributes" then he must also provide a list of all custom attribute names in the
demisto.args dict under the field "custom_data". If not provided, an error msg will be shown. If provided,
the function will return only the custom attributes mentioned in the custom_data list.
If the user has chosen "custom attributes group name" the handling of this option is similar to the "custom" option.
:param custom_attribute_group_list: the raw list of custom attributes group (as returned from the request)
:param args: demisto.args
:return: the parsed custom attributes list
"""
custom_attributes_flag = args.get('custom_attributes')
custom_attributes_list: list = []
# all case
if custom_attributes_flag == 'all':
for group in custom_attribute_group_list:
custom_attributes_list.extend(get_all_group_custom_attributes(group))
# custom attributes group name case
elif custom_attributes_flag == 'custom attributes group name':
custom_data = args.get('custom_data')
if not custom_data:
raise DemistoException('When choosing the group value for custom_attributes argument - the custom_data'
' list must be filled with group names. For example: custom_value=g1,g2,g3')
group_name_list: list = argToList(custom_data, ',')
for group in custom_attribute_group_list:
if group.get('name') in group_name_list:
custom_attributes_list.extend(get_all_group_custom_attributes(group))
# specific attributes case
elif custom_attributes_flag == 'specific attributes':
custom_data = args.get('custom_data')
if not custom_data:
raise DemistoException('When choosing the custom value for custom_attributes argument - the custom_data'
' list must be filled with custom attribute names.'
' For example: custom_value=ca1,ca2,ca3')
custom_attribute_name_list: list = argToList(custom_data, ',')
for group in custom_attribute_group_list:
for raw_custom_attribute in group.get('customAttribute', []):
custom_attribute_name: str = raw_custom_attribute.get('name')
if custom_attribute_name in custom_attribute_name_list:
custom_attribute: dict = {'Name': custom_attribute_name}
custom_attribute_value = raw_custom_attribute.get('value')
if custom_attribute_value:
custom_attribute['Value'] = custom_attribute_value
custom_attributes_list.append(custom_attribute)
# none case - If custom_attributes_flag == 'none' than we return empty list
return custom_attributes_list
def get_incident_details(raw_incident_details: dict, args: dict) -> dict:
"""
Parses the needed incident details into context paths
:param raw_incident_details: the raw response of the incident details
:param args: demisto.args
:return: the parsed dict
"""
incident: dict = raw_incident_details.get('incident', {})
message_source: dict = incident.get('messageSource', {})
message_type: dict = incident.get('messageType', {})
policy: dict = incident.get('policy', {})
incident_details: dict = {
'ID': raw_incident_details.get('incidentID'),
'LongID': raw_incident_details.get('incidentLongId'),
'StatusCode': raw_incident_details.get('statusCode'),
'CreationDate': incident.get('incidentCreationDate'),
'DetectionDate': incident.get('detectionDate'),
'Severity': incident.get('severity'),
'Status': incident.get('status'),
'MessageSource': message_source.get('_value_1'),
'MessageSourceType': message_source.get('sourceType'),
'MessageType': message_type.get('_value_1'),
'MessageTypeID': message_type.get('typeId'),
'Policy(val.ID && val.ID === obj.ID)': {
'Name': policy.get('name'),
'Version': policy.get('version'),
'Label': policy.get('label'),
'ID': policy.get('policyId')
},
'ViolatedPolicyRule(val.ID && val.ID === obj.ID)':
parse_violated_policy_rule(incident.get('violatedPolicyRule', [])),
'OtherViolatedPolicy(val.ID && val.ID === obj.ID)':
parse_other_violated_policy(incident.get('otherViolatedPolicy', [])),
'BlockedStatus': incident.get('blockedStatus'),
'MatchCount': incident.get('matchCount'),
'RuleViolationCount': incident.get('ruleViolationCount'),
'DetectionServer': incident.get('detectionServer'),
'CustomAttribute': parse_custom_attribute(incident.get('customAttributeGroup', []), args),
'DataOwner': get_data_owner(incident.get('dataOwner', {})),
'EventDate': incident.get('eventDate')
}
return {key: val for key, val in incident_details.items() if val}
def get_incident_attributes(attributes: dict) -> dict:
"""
Transforms the demisto args entered by the user into a dict representing the attributes
of the updated incidents
:param attributes: the demisto args dict
:return: the attributes dict by the API design
"""
# Verify Custom Attribute
custom_attribute: dict = {}
custom_attribute_name: str = attributes.get('custom_attribute_name', '')
custom_attribute_value: str = attributes.get('custom_attribute_value', '')
if custom_attribute_name and not custom_attribute_value or custom_attribute_value and not custom_attribute_name:
raise DemistoException("If updating an incident's custom attribute,"
" both custom_attribute_name and custom_attribute_value must be provided.")
elif custom_attribute_name and custom_attribute_value:
custom_attribute['value'] = custom_attribute_value
custom_attribute['name'] = custom_attribute_name
# Verify Data Owner
data_owner: dict = {}
data_owner_name: str = attributes.get('data_owner_name', '')
data_owner_email: str = attributes.get('data_owner_email', '')
if data_owner_name and not data_owner_email or data_owner_email and not data_owner_name:
raise DemistoException("If updating an incident's data owner,"
" both data_owner_name and data_owner_email must be provided.")
elif data_owner_name and data_owner_email:
data_owner['name'] = data_owner_name
data_owner['email'] = data_owner_email
# Verify Note
note: dict = {}
note_str: str = attributes.get('note', '')
note_time_str: str = attributes.get('note_time', '')
note_time = None
if note_time_str:
note_time = parse(note_time_str)
if note_str and not note_time or note_time and not note_str:
raise DemistoException("If adding an incident's note, both note and note_time must be provided.")
elif note_str and note_time:
note['note'] = note_str
note['dateAndTime'] = note_time
attributes: dict = {
'severity': attributes.get('severity'),
'status': attributes.get('status'),
'note': note,
'customAttribute': custom_attribute,
'dataOwner': data_owner,
'remediationStatus': attributes.get('remediation_status'),
'remediationLocation': attributes.get('remediation_location')
}
return {key: val for key, val in attributes.items() if val}
def parse_component(raw_components: list) -> list:
"""
Parses a list of components into a list of context data
:param raw_components: the components list before parsing
:return: the parsed list
"""
components: list = []
for raw_component in raw_components:
unfiltered_component: dict = {
'ID': raw_component.get('componentId'),
'Name': raw_component.get('name'),
'TypeID': raw_component.get('componentTypeId'),
'Type': raw_component.get('componentType'),
'Content': bytes_to_string(raw_component.get('content')),
'LongID': raw_component.get('componentLongId')
}
component: dict = {key: val for key, val in unfiltered_component.items() if val}
if component:
components.append(component)
return components
def datetime_to_iso_format(obj: Any):
"""
Converts a datetime object into an ISO string representation
:param obj: Any type of object
:return: If the object is of type datetime the return is it's ISO string representation
"""
if isinstance(obj, datetime):
return obj.isoformat()
def bytes_to_string(obj: Any):
"""
Converts a bytes object into a string
:param obj: Any type of object
:return: If the object is of type bytes it returns it's string representation, else returns
the object itself
"""
if isinstance(obj, bytes):
return obj.decode('utf-8')
else:
return obj
''' COMMANDS + REQUESTS FUNCTIONS '''
def test_module(client: Client, saved_report_id: int):
"""
Performs basic get request to get item samples
"""
helpers.serialize_object(client.service.incidentList(
savedReportId=saved_report_id,
incidentCreationDateLaterThan=parse_date_range('1 year')[0]
))
demisto.results('ok')
def get_incident_details_command(client: Client, args: dict) -> Tuple[str, dict, dict]:
incident_id: str = args.get('incident_id', '')
raw_incident: list = client.service.incidentDetail(
incidentId=incident_id,
includeHistory=True,
includeViolations=True
)
human_readable: str
entry_context: dict = {}
raw_response: dict = {}
if raw_incident and isinstance(raw_incident, list):
serialized_incident = helpers.serialize_object(raw_incident[0])
raw_response = json.loads(json.dumps(serialized_incident, default=datetime_to_iso_format))
incident_details: dict = get_incident_details(raw_response, args)
raw_headers = ['ID', 'CreationDate', 'DetectionDate', 'Severity', 'Status', 'MessageSourceType',
'MessageType', 'Policy Name']
headers = ['ID', 'Creation Date', 'Detection Date', 'Severity', 'Status', 'DLP Module',
'DLP Module subtype', 'Policy Name']
outputs: dict = {}
for raw_header in raw_headers:
if raw_header == 'Policy Name':
outputs['Policy Name'] = incident_details.get('Policy', {}).get('Name')
else:
outputs[headers[raw_headers.index(raw_header)]] = incident_details.get(raw_header)
human_readable = tableToMarkdown(f'Symantec DLP incident {incident_id} details', outputs, headers=headers,
removeNull=True)
entry_context = {'SymantecDLP.Incident(val.ID && val.ID === obj.ID)': incident_details}
else:
human_readable = 'No incident found.'
return human_readable, entry_context, raw_response
def list_incidents_command(client: Client, args: dict, saved_report_id: str) -> Tuple[str, dict, dict]:
if not saved_report_id:
raise ValueError('Missing saved report ID. Configure it in the integration instance settings.')
creation_date = parse_date_range(args.get('creation_date', '1 day'))[0]
raw_incidents = client.service.incidentList(
savedReportId=saved_report_id,
incidentCreationDateLaterThan=creation_date
)
human_readable: str
entry_context: dict = {}
raw_response: dict = {}
if raw_incidents:
serialized_incidents: dict = helpers.serialize_object(raw_incidents)
incidents_ids_list = serialized_incidents.get('incidentId')
if incidents_ids_list:
raw_response = serialized_incidents
incidents = [{'ID': str(incident_id)} for incident_id in incidents_ids_list]
human_readable = tableToMarkdown('Symantec DLP incidents', incidents, removeNull=True)
entry_context = {'SymantecDLP.Incident(val.ID && val.ID == obj.ID)': incidents}
else:
human_readable = 'No incidents found.'
else:
human_readable = 'No incidents found.'
return human_readable, entry_context, raw_response
def update_incident_command(client: Client, args: dict) -> Tuple[str, dict, dict]:
incident_id: str = args.get('incident_id', '')
incident_attributes: dict = get_incident_attributes(args)
raw_incidents_update_response = client.service.updateIncidents(
updateBatch={
'batchId': '_' + str(uuid.uuid1()),
'incidentId': incident_id,
'incidentAttributes': incident_attributes
}
)
human_readable: str
entry_context: dict = {}
raw_response: dict = {}
if raw_incidents_update_response and isinstance(raw_incidents_update_response, list):
incidents_update_response = helpers.serialize_object(raw_incidents_update_response[0])
headers: list = ['Batch ID', 'Inaccessible Incident Long ID', 'Inaccessible Incident ID', 'Status Code']
outputs = {
'Batch ID': incidents_update_response.get('batchId'),
'Inaccessible Incident Long ID': incidents_update_response.get('InaccessibleIncidentLongId'),
'Inaccessible Incident ID': incidents_update_response.get('InaccessibleIncidentId'),
'Status Code': incidents_update_response.get('statusCode')
}
if outputs.get('Status Code') == 'VALIDATION_ERROR':
raise DemistoException('Update was not successful. ADVICE: If status or custom attribute were changed,'
' check that they are configured in Symantec DLP.')
human_readable = tableToMarkdown(f'Symantec DLP incidents {incident_id} update', outputs, headers=headers,
removeNull=True)
else:
human_readable = 'Update was not successful'
return human_readable, entry_context, raw_response
def incident_binaries_command(client: Client, args: dict) -> Tuple[str, dict, list, dict]:
incident_id: str = args.get('incident_id', '')
include_original_message: bool = bool(args.get('include_original_message', 'True'))
include_all_components: bool = bool(args.get('include_all_components', 'True'))
human_readable, entry_context, file_entries, raw_response = get_incident_binaries(client, incident_id,
include_original_message,
include_all_components)
return human_readable, entry_context, file_entries, raw_response
def list_custom_attributes_command(client: Client) -> Tuple[str, dict, dict]:
raw_custom_attributes_list = client.service.listCustomAttributes()
human_readable: str
entry_context: dict = {}
raw_response: dict = {}
if raw_custom_attributes_list:
custom_attributes_list = helpers.serialize_object(raw_custom_attributes_list)
raw_response = custom_attributes_list
outputs: list = [{'Custom Attribute': custom_attribute} for custom_attribute in custom_attributes_list]
human_readable = tableToMarkdown('Symantec DLP custom attributes', outputs, removeNull=True)
else:
human_readable = 'No custom attributes found.'
return human_readable, entry_context, raw_response
def list_incident_status_command(client: Client) -> Tuple[str, dict, dict]:
raw_incident_status_list = client.service.listIncidentStatus()
human_readable: str
entry_context: dict = {}
raw_response: dict = {}
if raw_incident_status_list:
incident_status_list = helpers.serialize_object(raw_incident_status_list)
raw_response = incident_status_list
outputs: list = [{'Incident Status': incident_status} for incident_status in incident_status_list]
human_readable = tableToMarkdown('Symantec DLP incident status', outputs, removeNull=True)
else:
human_readable = 'No incident status found.'
return human_readable, entry_context, raw_response
def incident_violations_command(client: Client, args: dict) -> Tuple[str, dict, dict]:
incident_id: str = args.get('incident_id', '')
include_image_violations: bool = bool(args.get('include_image_violations', 'True'))
raw_incident_violations = client.service.incidentViolations(
incidentId=incident_id,
includeImageViolations=include_image_violations
)
human_readable: str
entry_context: dict = {}
raw_response: dict = {}
if raw_incident_violations:
raw_incident_violations = helpers.serialize_object(raw_incident_violations[0])
raw_response = raw_incident_violations
incident_violations: dict = {
'ID': raw_incident_violations.get('incidentId'),
'LongID': raw_incident_violations.get('incidentLongId'),
'StatusCode': raw_incident_violations.get('statusCode'),
'ViolatingComponent': parse_violating_component(raw_incident_violations.get('violatingComponent', []))
}
human_readable = tableToMarkdown(f'Symantec DLP incident {incident_id} violations',
{'ID': incident_violations.get('ID')}, removeNull=True)
entry_context = {'SymantecDLP.Incident(val.ID && val.ID === obj.ID)': incident_violations}
else:
human_readable = 'No incident status found.'
return human_readable, entry_context, raw_response
def fetch_incidents(client: Client, fetch_time: str, fetch_limit: int, last_run: dict, saved_report_id: str):
"""
Performs the fetch incidents functionality of Demisto, which means that every minute if fetches incidents
from Symantec DLP and uploads them to Demisto server.
:param client: Demisto Client
:param fetch_time: For the first time the integration is enabled with the fetch incidents functionality, the fetch
time indicates from what time to start fetching existing incidents in Symantec DLP system.
:param fetch_limit: Indicates how many incidents to fetch every minute
:param last_run: Demisto last run object
:param saved_report_id: The report ID to retrieve the incidents from
:return: A list of Demisto incidents
"""
# We use parse to get out time in datetime format and not iso, that's what Symantec DLP is expecting to get
last_id_fetched = last_run.get('last_incident_id')
if last_run and last_run.get('last_fetched_event_iso'):
last_update_time = parse(last_run['last_fetched_event_iso'])
else:
last_update_time = parse_date_range(fetch_time)[0]
incidents = []
incidents_ids = helpers.serialize_object(client.service.incidentList(
savedReportId=saved_report_id,
incidentCreationDateLaterThan=last_update_time
)).get('incidentId', '')
if incidents_ids:
incidents_ids = incidents_ids[:fetch_limit]
last_incident_time: str = ''
last_incident_id: str = ''
for incident_id in incidents_ids:
if last_id_fetched and last_id_fetched == incident_id:
# Skipping last incident from last cycle if fetched again
continue
incident_details = json.dumps(helpers.serialize_object(client.service.incidentDetail(
incidentId=incident_id
)[0]), default=datetime_to_iso_format)
incident_creation_time = json.loads(incident_details).get('incident', {}).get('incidentCreationDate')
incident: dict = {
'rawJSON': incident_details,
'name': f'Symantec DLP incident {incident_id}',
'occurred': incident_creation_time
}
_, _, file_entries, _ = get_incident_binaries(client, incident_id, False, False)
if file_entries:
attachments: list = []
for file_entry in file_entries:
attachments.append({
'path': file_entry['FileID'],
'name': file_entry['File']
})
incident['attachment'] = attachments
incidents.append(incident)
if incident_id == incidents_ids[-1]:
last_incident_time = incident_creation_time
last_incident_id = incident_id
demisto.setLastRun(
{
'last_fetched_event_iso': last_incident_time,
'last_incident_id': last_incident_id
}
)
demisto.incidents(incidents)
''' COMMANDS MANAGER / SWITCH PANEL '''
def main():
handle_proxy()
params: Dict = demisto.params()
server: str = params.get('server', '').rstrip('/')
credentials: Dict = params.get('credentials', {})
username: str = credentials.get('identifier', '')
password: str = credentials.get('password', '')
fetch_time: str = params.get('fetch_time', '3 days').strip()
try:
fetch_limit: int = int(params.get('fetch_limit', '10'))
except ValueError:
raise DemistoException('Value for fetch_limit must be an integer.')
saved_report_id: str = demisto.params().get('saved_report_id', '')
last_run: dict = demisto.getLastRun()
args: dict = demisto.args()
verify_ssl = not params.get('insecure', False)
wsdl: str = f'{server}/ProtectManager/services/v2011/incidents?wsdl'
session: Session = Session()
session.auth = SymantecAuth(username, password, server)
session.verify = verify_ssl
cache: SqliteCache = SqliteCache(path=get_cache_path(), timeout=None)
transport: Transport = Transport(session=session, cache=cache)
settings: Settings = Settings(strict=False, xsd_ignore_sequence_order=True)
client: Client = Client(wsdl=wsdl, transport=transport, settings=settings)
command = demisto.command()
demisto.info(f'Command being called is {command}')
commands = {
'test-module': test_module,
'fetch-incidents': fetch_incidents,
'symantec-dlp-get-incident-details': get_incident_details_command,
'symantec-dlp-list-incidents': list_incidents_command,
'symantec-dlp-update-incident': update_incident_command,
'symantec-dlp-incident-binaries': incident_binaries_command,
'symantec-dlp-list-custom-attributes': list_custom_attributes_command,
'symantec-dlp-list-incident-status': list_incident_status_command,
'symantec-dlp-incident-violations': incident_violations_command
}
try:
if command == 'fetch-incidents':
fetch_incidents(client, fetch_time, fetch_limit, last_run, saved_report_id) # type: ignore[operator]
elif command == 'test-module':
test_module(client, saved_report_id) # type: ignore[arg-type]
elif command == 'symantec-dlp-list-incidents':
human_readable, context, raw_response =\
commands[command](client, args, saved_report_id) # type: ignore[operator]
return_outputs(human_readable, context, raw_response)
elif command == 'symantec-dlp-list-incident-status' or command == 'symantec-dlp-list-custom-attributes':
human_readable, context, raw_response = commands[command](client) # type: ignore[operator]
return_outputs(human_readable, context, raw_response)
elif command == 'symantec-dlp-incident-binaries':
human_readable, context, file_entries, raw_response =\
commands[command](client, args) # type: ignore[operator]
return_outputs(human_readable, context, raw_response)
for file_entry in file_entries:
demisto.results(file_entry)
elif command in commands:
human_readable, context, raw_response = commands[command](client, args) # type: ignore[operator]
return_outputs(human_readable, context, raw_response)
# Log exceptions
except Exception as e:
err_msg = f'Error in Symantec DLP integration: {str(e)}'
if demisto.command() == 'fetch-incidents':
LOG(err_msg)
LOG.print_log()
raise
else:
return_error(err_msg, error=e)
if __name__ == 'builtins':
main()
|
1679407
|
import cv2
from math import ceil
import numpy as np
def floyd_steinberg_dither(img):
'''Applies the Floyd-Steinberf dithering to img, in place.
img is expected to be a 8-bit grayscale image.
Algorithm borrowed from wikipedia.org/wiki/Floyd%E2%80%93Steinberg_dithering.
'''
h, w = img.shape
def adjust_pixel(y, x, delta):
if y < 0 or y >= h or x < 0 or x >= w:
return
img[y][x] = min(255, max(0, img[y][x] + delta))
for y in range(h):
for x in range(w):
new_val = 255 if img[y][x] > 127 else 0
err = img[y][x] - new_val
img[y][x] = new_val
adjust_pixel(y, x + 1, err * 7/16)
adjust_pixel(y + 1, x - 1, err * 3/16)
adjust_pixel(y + 1, x, err * 5/16)
adjust_pixel(y + 1, x + 1, err * 1/16)
return img
def halfdone_dither(img):
'''Applies Haltone dithering using different sized circles
Algorithm is borrowed from https://github.com/GravO8/halftone
'''
def square_avg_value(square):
'''
Calculates the average grayscale value of the pixels in a square of the
original image
Argument:
square: List of N lists, each with N integers whose value is between 0
and 255
'''
sum = 0
n = 0
for row in square:
for pixel in row:
sum += pixel
n += 1
return sum/n
side = 4
jump = 4 # Todo: make this configurable
alpha = 3
height, width = img.shape
if not jump:
jump = ceil(min(height, height)*0.007)
assert jump > 0, "jump must be greater than 0"
height_output, width_output = side*ceil(height/jump), side*ceil(width/jump)
canvas = np.zeros((height_output, width_output, 3), np.uint8)
output_square = np.zeros((side, side, 3), np.uint8)
x_output, y_output = 0, 0
for y in range(0, height, jump):
for x in range(0, width, jump):
output_square[:] = (255, 255, 255)
intensity = 1 - square_avg_value(img[y:y+jump, x:x+jump])/255
radius = int(alpha*intensity*side/2)
if radius > 0:
# draw a circle
cv2.circle(
output_square,
center=(side//2, side//2),
radius=radius,
color=(0, 0, 0),
thickness=-1,
lineType=cv2.FILLED
)
# place the square on the canvas
canvas[y_output:y_output+side,
x_output:x_output+side] = output_square
x_output += side
y_output += side
x_output = 0
return canvas
def read_img(
filename,
print_width,
logger,
img_binarization_algo,
show_preview):
im = cv2.imread(filename, cv2.IMREAD_GRAYSCALE)
height = im.shape[0]
width = im.shape[1]
factor = print_width / width
resized = cv2.resize(
im,
(
int(width * factor),
int(height * factor)
),
interpolation=cv2.INTER_AREA)
if img_binarization_algo == 'floyd-steinberg':
logger.info('⏳ Applying Floyd-Steinberg dithering to image...')
resized = floyd_steinberg_dither(resized)
logger.info('✅ Done.')
resized = resized > 127
elif img_binarization_algo == 'halftone':
logger.info('⏳ Applying halftone dithering to image...')
resized = halfdone_dither(resized)
logger.info('✅ Done.')
resized = resized > 127
elif img_binarization_algo == 'mean-threshold':
resized = resized > resized.mean()
else:
logger.error(
f'🛑 Unknown image binarization algorithm: {img_binarization_algo}')
raise RuntimeError(
f'unknown image binarization algorithm: {img_binarization_algo}')
if show_preview:
# Convert from our boolean representation to float.
preview_img = resized.astype(float)
cv2.imshow('Preview', preview_img)
logger.info('ℹ️ Displaying preview.')
# Calling waitKey(1) tells OpenCV to process its GUI events and actually display our image.
cv2.waitKey(1)
if input('🤔 Go ahead with print? [Y/n]? ').lower() == 'n':
logger.info('🛑 Aborted print.')
return None
# Invert the image before returning it.
return ~resized
|
1679447
|
from PyObjCTools.TestSupport import *
import sys
from CoreFoundation import *
class TestByteOrder (TestCase):
def testConstants(self):
self.assertEqual(CFByteOrderUnknown , 0)
self.assertEqual(CFByteOrderLittleEndian , 1)
self.assertEqual(CFByteOrderBigEndian , 2)
def testCurrent(self):
if sys.byteorder == 'little':
self.assertTrue(CFByteOrderGetCurrent(), CFByteOrderLittleEndian)
else:
self.assertTrue(CFByteOrderGetCurrent(), CFByteOrderBigEndian)
def testSwap(self):
v = CFSwapInt16(0x1)
self.assertEqual(v , 1 << 8)
v = CFSwapInt32(0x1)
self.assertEqual(v , 1 << 24)
v = CFSwapInt64(0x1)
self.assertEqual(v , 1 << 56)
if sys.byteorder == 'big':
v = CFSwapInt16BigToHost(0x1)
self.assertEqual(v, 1)
v = CFSwapInt32BigToHost(0x1)
self.assertEqual(v, 1)
v = CFSwapInt64BigToHost(0x1)
self.assertEqual(v, 1)
v = CFSwapInt16HostToBig(0x1)
self.assertEqual(v, 1)
v = CFSwapInt32HostToBig(0x1)
self.assertEqual(v, 1)
v = CFSwapInt64HostToBig(0x1)
self.assertEqual(v, 1)
else:
v = CFSwapInt16BigToHost(0x1)
self.assertEqual(v, 1 << 8)
v = CFSwapInt32BigToHost(0x1)
self.assertEqual(v, 1 << 24)
v = CFSwapInt64BigToHost(0x1)
self.assertEqual(v, 1 << 56)
v = CFSwapInt16HostToBig(0x1)
self.assertEqual(v, 1 << 8)
v = CFSwapInt32HostToBig(0x1)
self.assertEqual(v, 1 << 24)
v = CFSwapInt64HostToBig(0x1)
self.assertEqual(v, 1 << 56)
if sys.byteorder == 'little':
v = CFSwapInt16LittleToHost(0x1)
self.assertEqual(v, 1)
v = CFSwapInt32LittleToHost(0x1)
self.assertEqual(v, 1)
v = CFSwapInt64LittleToHost(0x1)
self.assertEqual(v, 1)
v = CFSwapInt16HostToLittle(0x1)
self.assertEqual(v, 1)
v = CFSwapInt32HostToLittle(0x1)
self.assertEqual(v, 1)
v = CFSwapInt64HostToLittle(0x1)
self.assertEqual(v, 1)
else:
v = CFSwapInt16LittleToHost(0x1)
self.assertEqual(v, 1 << 8)
v = CFSwapInt32LittleToHost(0x1)
self.assertEqual(v, 1 << 24)
v = CFSwapInt64LittleToHost(0x1)
self.assertEqual(v, 1 << 56)
v = CFSwapInt16HostToLittle(0x1)
self.assertEqual(v, 1 << 8)
v = CFSwapInt32HostToLittle(0x1)
self.assertEqual(v, 1 << 24)
v = CFSwapInt64HostToLittle(0x1)
self.assertEqual(v, 1 << 56)
swapped = CFConvertFloat32HostToSwapped(2.5)
self.assertIsInstance(swapped, CFSwappedFloat32)
v = CFConvertFloat32SwappedToHost(swapped)
self.assertEqual(v , 2.5)
swapped = CFConvertFloat64HostToSwapped(2.5)
self.assertIsInstance(swapped, CFSwappedFloat64)
v = CFConvertFloat64SwappedToHost(swapped)
self.assertEqual(v , 2.5)
swapped = CFConvertFloatHostToSwapped(2.5)
self.assertIsInstance(swapped, CFSwappedFloat32)
v = CFConvertFloatSwappedToHost(swapped)
self.assertEqual(v , 2.5)
swapped = CFConvertDoubleHostToSwapped(2.5)
self.assertIsInstance(swapped, CFSwappedFloat64)
v = CFConvertDoubleSwappedToHost(swapped)
self.assertEqual(v , 2.5)
if __name__ == "__main__":
main()
|
1679463
|
from unittest import mock
import pytest
from h.models import Feature
@pytest.mark.usefixtures("features_override", "features_pending_removal_override")
class TestFeature:
def test_description_returns_hardcoded_description(self):
feat = Feature(name="notification")
assert feat.description == "A test flag for testing with."
def test_all_creates_annotations_that_dont_exist(self, db_session):
features = Feature.all(db_session)
assert len(features) == 1
assert features[0].name == "notification"
def test_all_only_returns_current_flags(self, db_session):
"""The .all() method should only return named current feature flags."""
new, pending, old = [
Feature(name="notification"),
Feature(name="abouttoberemoved"),
Feature(name="somethingelse"),
]
db_session.add_all([new, pending, old])
db_session.flush()
features = Feature.all(db_session)
assert len(features) == 1
assert features[0].name == "notification"
def test_remove_old_flag_removes_old_flags(self, db_session):
"""
The remove_old_flags function should remove unknown flags.
New flags and flags pending removal should be left alone, but completely
unknown flags should be removed.
"""
new, pending, old = [
Feature(name="notification"),
Feature(name="abouttoberemoved"),
Feature(name="somethingelse"),
]
db_session.add_all([new, pending, old])
db_session.flush()
Feature.remove_old_flags(db_session)
remaining = {f.name for f in db_session.query(Feature).all()}
assert remaining == {"abouttoberemoved", "notification"}
@pytest.fixture
def features_override(self, request):
# Replace the primary FEATURES dictionary for the duration of testing...
patcher = mock.patch.dict(
"h.models.feature.FEATURES",
{"notification": "A test flag for testing with."},
clear=True,
)
patcher.start()
request.addfinalizer(patcher.stop)
@pytest.fixture
def features_pending_removal_override(self, request):
# And configure 'abouttoberemoved' as a feature pending removal...
patcher = mock.patch.dict(
"h.models.feature.FEATURES_PENDING_REMOVAL",
{"abouttoberemoved": "A test flag that's about to be removed."},
clear=True,
)
patcher.start()
request.addfinalizer(patcher.stop)
|
1679486
|
import boto3
import boto3.session
import json
from keydra.providers.base import BaseProvider
from keydra.providers.base import exponential_backoff_retry
from keydra.exceptions import DistributionException
from typing import Dict, NamedTuple, Optional
from keydra.exceptions import RotationException
from keydra.clients.aws.secretsmanager import GetSecretException
from keydra.clients.aws.secretsmanager import InsertSecretException
from keydra.clients.aws.secretsmanager import SecretsManagerClient
from keydra.clients.aws.secretsmanager import UpdateSecretException
from keydra.logging import get_logger
LOGGER = get_logger()
class SecretsManagerProvider(BaseProvider):
def __init__(
self,
session=None,
client: SecretsManagerClient = None,
region_name=None,
# credentials must be present for the loader to init the provider
credentials=None):
if session is None: # pragma: no cover
session = boto3.session.Session()
self._client = client or SecretsManagerClient(
session=session,
region_name=region_name
)
class Options(NamedTuple):
bypass: bool = False
rotate_attribute: Optional[str] = None
length: int = 32
exclude_char: str = ''
exclude_num: bool = False
exclude_punct: bool = False
exclude_upper: bool = False
exclude_lower: bool = False
include_space: bool = False
require_each_type: bool = True
def _distribute_secret(self, secret, dest):
current_secret = None
try:
current_secret = self._client.describe_secret(
secret_id=dest['key']
)
except GetSecretException as e:
print('not existing, ', e)
LOGGER.info(
'{} not present in SecretsManager: {}'.format(dest['key'], e)
)
try:
if current_secret:
print('present, updating ', dest)
LOGGER.info(
'{} is present in SecretsManager, updating.'.format(
dest['key']
)
)
self._client.update_secret(
secret_id=dest['key'],
secret_value=json.dumps(secret)
)
else:
print('not present, creating')
LOGGER.info(
'{} not present in SecretsManager, adding.'.format(
dest['key'],
)
)
self._client.create_secret(
secret_name=dest['key'],
secret_value=json.dumps(secret),
description='Keydra managed secret {}'.format(
dest['key']
)
)
except (InsertSecretException, UpdateSecretException) as e:
raise DistributionException(
'Error distributing {}: {}'.format(dest['key'], e)
)
LOGGER.info(
'Successfully distributed {} to SecretsManager'.format(
dest['key']
)
)
return dest
def _get_current_secret(self, secret_key):
try:
value = self._client.get_secret_value(secret_key)
# Assume that all secret values are formatted as valid JSON objects
obj = json.loads(value)
obj['provider'] = 'secretsmanager'
return obj
except Exception as e:
raise RotationException(e)
def _generate_secret_value(self, opts: Options) -> str:
return self._client.generate_random_password(
length=opts.length,
ExcludeCharacters=opts.exclude_char,
ExcludeNumbers=opts.exclude_num,
ExcludePunctuation=opts.exclude_punct,
ExcludeUppercase=opts.exclude_upper,
ExcludeLowercase=opts.exclude_lower,
IncludeSpace=opts.include_space,
RequireEachIncludedType=opts.require_each_type)
def rotate(self, spec) -> Dict[str, str]:
current_secret = self._get_current_secret(spec['key'])
options = SecretsManagerProvider.Options(**spec['config'])
if options.bypass:
LOGGER.debug('Bypassing rotation for {}'
.format(spec['key']))
return current_secret
LOGGER.debug('Rotating {} with options: {}'
.format(spec['key'], options))
current_secret[options.rotate_attribute] = \
self._generate_secret_value(options)
self._client.update_secret(
spec['key'],
json.dumps(current_secret))
return current_secret
@exponential_backoff_retry(3)
def distribute(self, secret, destination):
try:
return self._distribute_secret(secret, destination)
except Exception as e:
raise DistributionException(e)
@classmethod
def validate_spec(cls, spec):
valid, msg = BaseProvider.validate_spec(spec)
if not valid:
return False, msg
if ('config' in spec) == ('source' in spec):
return False, 'Must specify either "config" or \
"source", not both'
if 'source' in spec:
return True, 'All good!'
options = SecretsManagerProvider.Options(**spec['config'])
if options.bypass == (options.rotate_attribute is not None):
return False, 'Must specify either "bypass" or \
"rotate_attribute", not both'
return True, 'All good!'
@classmethod
def redact_result(cls, result, spec=None):
if 'value' in result:
for key, value in result['value'].items():
if key != 'provider':
result['value'][key] = '***'
return result
@classmethod
def has_creds(cls):
return False
|
1679487
|
from django.test import TestCase, Client
from django.contrib.auth.models import User
from datetime import datetime
from server.models import Computer, Secret, Request
class RequestProcess(TestCase):
def test_request_passes_correct_data_to_template(self):
admin = User.objects.create_superuser("admin", "<EMAIL>", "sekrit")
tech = User.objects.create_user("tech", "<EMAIL>", "password")
tech.save()
tech_test_computer = Computer(
serial="TECHSERIAL", username="Daft Tech", computername="compy587"
)
tech_test_computer.save()
test_secret = Secret(
computer=tech_test_computer,
secret="SHHH-DONT-TELL",
date_escrowed=datetime.now(),
)
test_secret.save()
secret_request = Request(secret=test_secret, requesting_user=tech)
secret_request.save()
client = Client()
login_response = self.client.post(
"/login/", {"username": "admin", "password": "<PASSWORD>"}, follow=True
)
response = self.client.get("/manage-requests/", follow=True)
print(response)
self.assertTrue(response.context["user"].is_authenticated)
|
1679503
|
import asyncio
from tracardi.service.singleton import Singleton
from tracardi.service.notation.dot_accessor import DotAccessor
from tracardi.process_engine.tql.parser import Parser
from tracardi.process_engine.tql.transformer.expr_transformer import ExprTransformer
class Condition(metaclass=Singleton):
def __init__(self):
self.parser = Parser(Parser.read('grammar/uql_expr.lark'), start='expr')
def parse(self, condition):
return self.parser.parse(condition)
async def evaluate(self, condition, dot: DotAccessor):
# todo cache tree
tree = self.parse(condition)
await asyncio.sleep(0)
return ExprTransformer(dot=dot).transform(tree)
|
1679536
|
import argparse
import logging
import sys
import typing
from pdfminer.layout import LAParams
from . import __doc__, __version__, process_file
from .printer import Printer
from .printer.markdown import MarkdownPrinter, GroupedMarkdownPrinter
from .printer.json import JsonPrinter
MD_FORMAT_ARGS = ['print_filename', 'remove_hyphens', 'wrap_column', 'condense', 'sections']
"""Named of arguments passed to the markdown printers."""
def _float_or_disabled(x: str) -> typing.Optional[float]:
if x.lower().strip() == "disabled":
return None
try:
return float(x)
except ValueError as ex:
raise argparse.ArgumentTypeError("invalid float value: {}".format(x)) from ex
def parse_args() -> typing.Tuple[argparse.Namespace, LAParams]:
p = argparse.ArgumentParser(prog='pdfannots', description=__doc__)
p.add_argument('--version', action='version',
version='%(prog)s ' + __version__)
p.add_argument("input", metavar="INFILE", type=argparse.FileType("rb"),
help="PDF files to process", nargs='+')
g = p.add_argument_group('Basic options')
g.add_argument("-p", "--progress", default=False, action="store_true",
help="Emit progress information to stderr.")
g.add_argument("-o", metavar="OUTFILE", type=argparse.FileType("w"), dest="output",
default=sys.stdout, help="Output file (default is stdout).")
g.add_argument("-n", "--cols", default=None, type=int, metavar="COLS", dest="cols",
help="Assume a fixed top-to-bottom left-to-right page layout with this many "
"columns per page. If unset, PDFMiner's layout detection logic is used.")
g.add_argument("--keep-hyphens", dest="remove_hyphens", default=True, action="store_false",
help="When capturing text across a line break, don't attempt to remove hyphens.")
g.add_argument("-f", "--format", choices=["md", "json"], default="md",
help="Output format (default: markdown).")
g = p.add_argument_group('Options controlling markdown output')
g.add_argument("-s", "--sections", metavar="SEC", nargs="*",
choices=GroupedMarkdownPrinter.ALL_SECTIONS,
default=GroupedMarkdownPrinter.ALL_SECTIONS,
help=("sections to emit (default: %s)" %
', '.join(GroupedMarkdownPrinter.ALL_SECTIONS)))
g.add_argument("--no-condense", dest="condense", default=True, action="store_false",
help="Emit annotations as a blockquote regardless of length.")
g.add_argument("--no-group", dest="group", default=True, action="store_false",
help="Emit annotations in order, don't group into sections.")
g.add_argument("--print-filename", dest="print_filename", default=False, action="store_true",
help="Print the name of each file with annotations.")
g.add_argument("-w", "--wrap", dest="wrap_column", metavar="COLS", type=int,
help="Wrap text at this many output columns.")
g = p.add_argument_group(
"Advanced options affecting PDFMiner text layout analysis")
laparams = LAParams()
g.add_argument(
"--line-overlap", metavar="REL_HEIGHT", type=float, default=laparams.line_overlap,
help="If two characters have more overlap than this they are considered to be "
"on the same line. The overlap is specified relative to the minimum height "
"of both characters. Default: %s" % laparams.line_overlap)
g.add_argument(
"--char-margin", metavar="REL_WIDTH", type=float, default=laparams.char_margin,
help="If two characters are closer together than this margin they "
"are considered to be part of the same line. The margin is "
"specified relative to the character width. Default: %s" % laparams.char_margin)
g.add_argument(
"--word-margin", metavar="REL_WIDTH", type=float, default=laparams.word_margin,
help="If two characters on the same line are further apart than this "
"margin then they are considered to be two separate words, and "
"an intermediate space will be added for readability. The margin "
"is specified relative to the character width. Default: %s" % laparams.word_margin)
g.add_argument(
"--line-margin", metavar="REL_HEIGHT", type=float, default=laparams.line_margin,
help="If two lines are close together they are considered to "
"be part of the same paragraph. The margin is specified "
"relative to the height of a line. Default: %s" % laparams.line_margin)
g.add_argument(
"--boxes-flow", type=_float_or_disabled, default=laparams.boxes_flow,
help="Specifies how much a horizontal and vertical position of a "
"text matters when determining the order of lines. The value "
"should be within the range of -1.0 (only horizontal position "
"matters) to +1.0 (only vertical position matters). You can also "
"pass 'disabled' to disable advanced layout analysis, and "
"instead return text based on the position of the bottom left "
"corner of the text box. Default: %s" % laparams.boxes_flow)
# The next two booleans are described as if they default off, so let's ensure that.
assert not laparams.detect_vertical
assert not laparams.all_texts
g.add_argument(
"--detect-vertical", default=laparams.detect_vertical,
action="store_const", const=(not laparams.detect_vertical),
help="Consider vertical text during layout analysis.")
g.add_argument(
"--all-texts", default=laparams.all_texts,
action="store_const", const=(not laparams.all_texts),
help="Perform layout analysis on text in figures.")
args = p.parse_args()
# Propagate parsed layout parameters back to LAParams object
for param in ("line_overlap", "char_margin", "word_margin", "line_margin",
"boxes_flow", "detect_vertical", "all_texts"):
setattr(laparams, param, getattr(args, param))
return args, laparams
def main() -> None:
args, laparams = parse_args()
logging.basicConfig(format='%(levelname)s: %(message)s',
level=logging.WARNING)
# construct appropriate Printer
printer: Printer
if args.format == "md":
mdargs = {k: getattr(args, k) for k in MD_FORMAT_ARGS}
printer = (GroupedMarkdownPrinter if args.group else MarkdownPrinter)(**mdargs)
elif args.format == "json":
printer = JsonPrinter(remove_hyphens=args.remove_hyphens)
def write_if_nonempty(s: str) -> None:
if s:
args.output.write(s)
write_if_nonempty(printer.begin())
# iterate over files
for file in args.input:
doc = process_file(
file,
columns_per_page=args.cols,
emit_progress_to=(sys.stderr if args.progress else None),
laparams=laparams)
for line in printer.print_file(file.name, doc):
args.output.write(line)
write_if_nonempty(printer.end())
|
1679620
|
from pyudemy import Udemy
from decouple import config
client_id = config('CLIENT_ID')
client_secret = config('CLIENT_SECRET')
udemy = Udemy(client_id, client_secret)
print(udemy.courses())
|
1679635
|
import json
from typing import List, NamedTuple
from . import BaseObject
class IDNamePair(NamedTuple):
"""Simple type used to help with unpacking event data"""
id: str
name: str
class InteractiveEvent(BaseObject):
response_url: str
user: IDNamePair
team: IDNamePair
channel: IDNamePair
raw_event: dict
def __init__(self, event: dict):
self.raw_event = event
self.response_url = event["response_url"]
class MessageInteractiveEvent(InteractiveEvent):
event_type: str
message_ts: str
trigger_id: str
action_id: str
block_id: str
message: dict
def __init__(self, event: dict):
"""
Convenience class to parse an interactive message payload from the events API
Args:
event: the raw event dictionary
"""
super().__init__(event)
self.user = IDNamePair(event["user"]["id"], event["user"]["username"])
self.team: IDNamePair = IDNamePair(event["team"]["id"], event["team"]["domain"])
self.channel: IDNamePair = IDNamePair(
event["channel"]["id"], event["channel"]["name"]
)
self.event_type = event["type"]
self.message_ts = event["message"]["ts"]
self.trigger_id = event["trigger_id"]
# actions payload is an array, but will only have one item (the action
# actually interacted with)
action = event["actions"][0]
self.action_id = action["action_id"]
self.block_id = action["block_id"]
if action.get("selected_option"):
self.value = action["selected_option"]["value"]
else:
self.value = action["value"]
self.message = event["message"]
class DialogInteractiveEvent(InteractiveEvent):
event_type: str
submission: dict
state: dict
def __init__(self, event: dict):
"""
Convenience class to parse a dialog interaction payload from the events API
Args:
event: the raw event dictionary
"""
super().__init__(event)
self.user = IDNamePair(event["user"]["id"], event["user"]["name"])
self.team = IDNamePair(event["team"]["id"], event["team"]["domain"])
self.channel = IDNamePair(event["channel"]["id"], event["channel"]["name"])
self.callback_id = event["callback_id"]
self.event_type = event["type"]
self.submission = event["submission"]
if event["state"]:
self.state = json.loads(event["state"])
else:
self.state = {}
def require_any(self, requirements: List[str]) -> dict:
"""
Convenience method to construct the 'errors' response to send directly back to
the invoking HTTP request
Args:
requirements: List of required dialog components, by name
"""
if any( # skipcq: PYL-R1705
self.submission.get(requirement, "") for requirement in requirements
):
return {}
else:
errors = []
for key in self.submission:
error_text = "At least one value is required"
errors.append({"name": key, "error": error_text})
return {"errors": errors}
class SlashCommandInteractiveEvent(InteractiveEvent):
trigger_id: str
command: str
text: str
def __init__(self, event: dict):
"""
Convenience class to parse a slash command payload from the events API
Args:
event: the raw event dictionary
"""
super().__init__(event)
self.user = IDNamePair(event["user_id"], event["user_name"])
self.channel = IDNamePair(event["channel_id"], event["channel_name"])
self.team = IDNamePair(event["team_id"], event["team_domain"])
self.trigger_id = event["trigger_id"]
self.command = event["command"]
self.text = event["text"]
@staticmethod
def create_reply(message, ephemeral=False) -> dict:
"""
Create a reply suitable to send directly back to the invoking HTTP request
Args:
message: Text to send
ephemeral: Whether the response should be limited to a single user, or to
broadcast the reply (_and_ the user's original invocation) to the
channel publicly
"""
if ephemeral: # skipcq: PYL-R1705
return {"text": message, "response_type": "ephemeral"}
else:
return {"text": message, "response_type": "in_channel"}
|
1679641
|
from analyzer.syntax_kind import SyntaxKind
class ParenthesizedExpressionSyntax(object):
def __init__(self, open_paren_token, expression, close_paren_token):
self.kind = SyntaxKind.ParenthesizedExpression
self.open_paren_token = open_paren_token
self.expression = expression
self.close_paren_token = close_paren_token
def __str__(self):
return f"{self.open_paren_token}{self.expression}{self.close_paren_token}"
|
1679722
|
import unittest
import urllib.parse
import urllib.request
import json
import argparse
import os
parser = argparse.ArgumentParser(description="Autoscorer")
parser.add_argument("filename", help="File to submit")
parser.add_argument("hash", help="Hash key")
args = parser.parse_args()
if args.hash:
hashkey = args.hash
if args.filename:
filename = args.filename
class TestResult(unittest.TextTestResult):
_previousTestClass = None
_testRunEntered = False
_moduleSetUpFailed = False
def __init__(self, stream=None, descriptions=None, verbosity=1):
super().__init__(
stream=stream, descriptions=descriptions, verbosity=verbosity)
self.tests_run = []
def getTestsReport(self):
"""Returns the run tests as a list of the form [test_id, result]"""
return self.tests_run
def addError(self, test, err):
"""Called when an error has occurred. 'err' is a tuple of values as
returned by sys.exc_info().
"""
super().addError(test, err)
self.errors.append((test, self._exc_info_to_string(err, test)))
self._mirrorOutput = True
self.tests_run.append([test.id(), 0])
def addFailure(self, test, err):
"""Called when an error has occurred. 'err' is a tuple of values as
returned by sys.exc_info()."""
super().addFailure(test, err)
self.failures.append((test, self._exc_info_to_string(err, test)))
self._mirrorOutput = True
self.tests_run.append([test.id(), 0])
def addSuccess(self, test):
"Called when a test has completed successfully"
super().addSuccess(test)
self.tests_run.append([test.id(), 1])
loader = unittest.loader.defaultTestLoader
null_stream = open(os.devnull, "w")
test_suite = loader.discover('.', '*_unit_test.py', None)
result = unittest.TextTestRunner(
stream=null_stream, verbosity=2, resultclass=TestResult).run(test_suite)
print("Generating result sheet...")
print("-------------------------------------------------------------------")
print(" Test Case | Passed? | Feedback")
print("-------------------------------------------------------------------")
for c, r in result.tests_run:
print("{0:s} | {1:s} | {2} ".format(
c.rsplit('.', 1)[1].rjust(25),
"PASSED" if r == 1 else "FAILED",
"Good Job".rjust(10) if r == 1 else "Failed".rjust(10)))
# print(json.dumps(result.tests_run))
print("Reading source file...")
file = open(filename, "r")
print("Transferring results to server...")
payload = {
'hashkey': hashkey,
'result': result.tests_run,
'code': file.read()
}
try:
data = urllib.parse.urlencode(payload)
data = data.encode('ascii')
req = urllib.request.Request('http://report.inflearn.com/submit', data)
with urllib.request.urlopen(req) as response:
resp = response.read()
if json.loads(resp)['result'] == 0:
print("Transfer failed: hash key is already used.")
else:
print("Transfer completed.")
except Exception as e:
print("Error occurred on transferring.", e)
|
1679724
|
from .registry import Registry, build_from_cfg
from .flops_counter import get_model_complexity_info
__all__ = ['Registry', 'build_from_cfg', 'get_model_complexity_info']
|
1679790
|
import logging
import configobj
# Adapted from click_config_file.configobj_provider so that we can store the
# file path that the config was loaded from in order to log it later.
log = logging
class ConfigProvider:
def __init__(self):
self.file_path = None
def __call__(self, file_path, cmd_name):
self.file_path = file_path
return configobj.ConfigObj(file_path, unrepr=True)
|
1679839
|
import pathlib
from time import time
import unittest
from text_recognizer.datasets.emnist import EmnistDataset
from text_recognizer.character_predictor import CharacterPredictor
SUPPORT_DIRNAME = pathlib.Path(__file__).parents[0].resolve() / 'support' / 'emnist'
class TestEvaluateCharacterPredictor(unittest.TestCase):
def test_evaluate(self):
predictor = CharacterPredictor()
dataset = EmnistDataset()
dataset.load_or_generate_data()
t = time()
metric = predictor.evaluate(dataset)
time_taken = time() - t
print(f'acc: {metric}, time_taken: {time_taken}')
self.assertGreater(metric, 0.7)
self.assertLess(time_taken, 10)
|
1679852
|
from __future__ import print_function
try:
from setuptools import setup, find_packages
except ImportError:
from distutils.core import setup, find_packages
import io
import codecs
import os
import sys
import iAnnotateSV
here = os.path.abspath(os.path.dirname(__file__))
def read(*filenames, **kwargs):
encoding = kwargs.get('encoding', 'utf-8')
sep = kwargs.get('sep', '\n')
buf = []
for filename in filenames:
with io.open(filename, encoding=encoding) as f:
buf.append(f.read())
return sep.join(buf)
long_description = read('README.rst', 'CHANGES.rst')
setup(
name='iCallSV',
version=iAnnotateSV.__version__,
description='The module helps to call structural variants using NGS data set on human.',
long_description=long_description,
include_package_data=True,
url='https://github.com/rhshah/iCallSV',
download_url='https://github.com/rhshah/iCallSV/tarball/0.0.7',
author=iAnnotateSV.__author__,
author_email='<EMAIL>',
license=iAnnotateSV.__license__,
platforms='any',
packages=['iCallSV'],
install_requires=[
'pandas==0.16.2',
'pysam==0.8.4',
'pyvcf=0.6.7',
'biopython=1.65',
'coloredlogs=5.2',
],
zip_safe=False,
classifiers=(
'Programming Language :: Python',
'Programming Language :: Python :: 2.7',
'License :: OSI Approved :: Apache License',
'Operating System :: OS Independent',
'Intended Audience :: Science/Research',
'Topic :: Scientific/Engineering :: Bio-Informatics',
'Development Status :: 3'
),
)
|
1679909
|
from __future__ import unicode_literals
from django.contrib.gis.db import models
class PointField(models.Model):
name = models.CharField(max_length=255)
location = models.PointField(srid=4326)
city = models.PointField(blank=True, null=True, srid=3857)
def __unicode__(self):
return self.name
class Street(models.Model):
point = models.ForeignKey(PointField, blank=True, null=True, on_delete=models.SET_NULL)
name = models.CharField(max_length=255)
street = models.PointField(srid=4326)
|
1680063
|
del_items(0x8013923C)
SetType(0x8013923C, "void PresOnlyTestRoutine__Fv()")
del_items(0x80139264)
SetType(0x80139264, "void FeInitBuffer__Fv()")
del_items(0x8013928C)
SetType(0x8013928C, "void FeAddEntry__Fii8TXT_JUSTUsP7FeTableP5CFont(int X, int Y, enum TXT_JUST Just, unsigned short Str, struct FeTable *MenuPtr, struct CFont *Font)")
del_items(0x80139300)
SetType(0x80139300, "void FeAddTable__FP11FeMenuTablei(struct FeMenuTable *Table, int Count)")
del_items(0x8013937C)
SetType(0x8013937C, "void FeAddNameTable__FPUci(unsigned char *Table, int Count)")
del_items(0x801394AC)
SetType(0x801394AC, "void FeDrawBuffer__Fv()")
del_items(0x801398C0)
SetType(0x801398C0, "void FeNewMenu__FP7FeTable(struct FeTable *Menu)")
del_items(0x80139940)
SetType(0x80139940, "void FePrevMenu__Fv()")
del_items(0x801399EC)
SetType(0x801399EC, "void FeSelUp__Fi(int No)")
del_items(0x80139AD4)
SetType(0x80139AD4, "void FeSelDown__Fi(int No)")
del_items(0x80139BB8)
SetType(0x80139BB8, "int FeGetCursor__Fv()")
del_items(0x80139BCC)
SetType(0x80139BCC, "void FeSelect__Fv()")
del_items(0x80139C10)
SetType(0x80139C10, "void FeMainKeyCtrl__FP7CScreen(struct CScreen *FeScreen)")
del_items(0x80139DA8)
SetType(0x80139DA8, "void InitDummyMenu__Fv()")
del_items(0x80139DB0)
SetType(0x80139DB0, "void InitFrontEnd__FP9FE_CREATE(struct FE_CREATE *CreateStruct)")
del_items(0x80139E70)
SetType(0x80139E70, "void FeInitMainMenu__Fv()")
del_items(0x80139ECC)
SetType(0x80139ECC, "void FeInitNewGameMenu__Fv()")
del_items(0x80139F1C)
SetType(0x80139F1C, "void FeNewGameMenuCtrl__Fv()")
del_items(0x8013A050)
SetType(0x8013A050, "void FeInitPlayer1ClassMenu__Fv()")
del_items(0x8013A0C4)
SetType(0x8013A0C4, "void FeInitPlayer2ClassMenu__Fv()")
del_items(0x8013A138)
SetType(0x8013A138, "void FePlayerClassMenuCtrl__Fv()")
del_items(0x8013A180)
SetType(0x8013A180, "void FeDrawChrClass__Fv()")
del_items(0x8013A61C)
SetType(0x8013A61C, "void FeInitNewP1NameMenu__Fv()")
del_items(0x8013A664)
SetType(0x8013A664, "void FeInitNewP2NameMenu__Fv()")
del_items(0x8013A6AC)
SetType(0x8013A6AC, "void FeNewNameMenuCtrl__Fv()")
del_items(0x8013ABFC)
SetType(0x8013ABFC, "void FeCopyPlayerInfoForReturn__Fv()")
del_items(0x8013ACCC)
SetType(0x8013ACCC, "void FeEnterGame__Fv()")
del_items(0x8013ACF4)
SetType(0x8013ACF4, "void FeInitLoadMemcardSelect__Fv()")
del_items(0x8013AD5C)
SetType(0x8013AD5C, "void FeInitLoadChar1Menu__Fv()")
del_items(0x8013ADC8)
SetType(0x8013ADC8, "void FeInitLoadChar2Menu__Fv()")
del_items(0x8013AE34)
SetType(0x8013AE34, "void FeInitDifficultyMenu__Fv()")
del_items(0x8013AE7C)
SetType(0x8013AE7C, "void FeDifficultyMenuCtrl__Fv()")
del_items(0x8013AF34)
SetType(0x8013AF34, "void FeInitBackgroundMenu__Fv()")
del_items(0x8013AF7C)
SetType(0x8013AF7C, "void FeInitBook1Menu__Fv()")
del_items(0x8013AFC8)
SetType(0x8013AFC8, "void FeInitBook2Menu__Fv()")
del_items(0x8013B014)
SetType(0x8013B014, "void FeBackBookMenuCtrl__Fv()")
del_items(0x8013B210)
SetType(0x8013B210, "void PlayDemo__Fv()")
del_items(0x8013B224)
SetType(0x8013B224, "void FadeFEOut__Fv()")
del_items(0x8013B2E8)
SetType(0x8013B2E8, "void DrawBackTSK__FP4TASK(struct TASK *T)")
del_items(0x8013B3E0)
SetType(0x8013B3E0, "void FrontEndTask__FP4TASK(struct TASK *T)")
del_items(0x8013B758)
SetType(0x8013B758, "void McMainCharKeyCtrl__Fv()")
del_items(0x8013BB60)
SetType(0x8013BB60, "void DrawFeTwinkle__Fii(int SelX, int SelY)")
del_items(0x8013BC20)
SetType(0x8013BC20, "void ___6Dialog(struct Dialog *this, int __in_chrg)")
del_items(0x8013BC48)
SetType(0x8013BC48, "struct Dialog *__6Dialog(struct Dialog *this)")
del_items(0x8013BCA4)
SetType(0x8013BCA4, "void ___7CScreen(struct CScreen *this, int __in_chrg)")
del_items(0x8013BCC4)
SetType(0x8013BCC4, "unsigned char CheckActive__4CPad(struct CPad *this)")
del_items(0x8013C874)
SetType(0x8013C874, "void InitCredits__Fv()")
del_items(0x8013C8B0)
SetType(0x8013C8B0, "int PrintCredits__FPciiiii(char *Str, int Y, int CharFade, int RFlag, int GFlag, int BFlag)")
del_items(0x8013D0D0)
SetType(0x8013D0D0, "void DrawCreditsTitle__Fiiiii(int TitleNo, int TitleFade, int TitleMode, int NextTitleNo, int Y)")
del_items(0x8013D19C)
SetType(0x8013D19C, "void DrawCreditsSubTitle__Fiiiii(int SubTitleNo, int SubTitleFade, int SubTitleMode, int NextSubTitleNo, int Y)")
del_items(0x8013D278)
SetType(0x8013D278, "void DoCredits__Fv()")
del_items(0x8013D4FC)
SetType(0x8013D4FC, "void PRIM_GetPrim__FPP8POLY_FT4(struct POLY_FT4 **Prim)")
del_items(0x8013D578)
SetType(0x8013D578, "int GetCharHeight__5CFontc(struct CFont *this, char ch)")
del_items(0x8013D5B0)
SetType(0x8013D5B0, "int GetCharWidth__5CFontc(struct CFont *this, char ch)")
del_items(0x8013D608)
SetType(0x8013D608, "void ___7CScreen_addr_8013D608(struct CScreen *this, int __in_chrg)")
del_items(0x8013D628)
SetType(0x8013D628, "struct FRAME_HDR *GetFr__7TextDati(struct TextDat *this, int FrNum)")
del_items(0x80141C20)
SetType(0x80141C20, "void endian_swap__FPUci(unsigned char *b, int byts)")
del_items(0x80141C54)
SetType(0x80141C54, "unsigned short to_sjis__Fc(char asc)")
del_items(0x80141CD4)
SetType(0x80141CD4, "char to_ascii__FUs(unsigned short sjis)")
del_items(0x80141D54)
SetType(0x80141D54, "void ascii_to_sjis__FPcPUs(char *asc, unsigned short *sjis)")
del_items(0x80141DE8)
SetType(0x80141DE8, "void sjis_to_ascii__FPUsPc(unsigned short *sjis, char *asc)")
del_items(0x80141E70)
SetType(0x80141E70, "int test_hw_event__Fv()")
del_items(0x80141F00)
SetType(0x80141F00, "void read_card_directory__Fi(int card_number)")
del_items(0x80142138)
SetType(0x80142138, "int test_card_format__Fi(int card_number)")
del_items(0x801421C8)
SetType(0x801421C8, "int checksum_data__FPci(char *buf, int size)")
del_items(0x80142204)
SetType(0x80142204, "int delete_card_file__Fii(int card_number, int file)")
del_items(0x801422FC)
SetType(0x801422FC, "int read_card_file__FiiiPc(int card_number, int file, int id, char *buf)")
del_items(0x801424B4)
SetType(0x801424B4, "int format_card__Fi(int card_number)")
del_items(0x80142564)
SetType(0x80142564, "int write_card_file__FiiPcT2PUcPUsiT4(int card_number, int id, char *name, char *title, unsigned char *icon, unsigned short *clut, int size, unsigned char *buf)")
del_items(0x801428AC)
SetType(0x801428AC, "void new_card__Fi(int card_number)")
del_items(0x80142928)
SetType(0x80142928, "void service_card__Fi(int card_number)")
del_items(0x8015CB18)
SetType(0x8015CB18, "int GetFileNumber__FiPc(int side, char *file_name)")
del_items(0x8015CBD8)
SetType(0x8015CBD8, "int DoSaveOptions__Fv()")
del_items(0x8015CC2C)
SetType(0x8015CC2C, "int DoSaveCharacter__FPc(char *savefilename)")
del_items(0x8015CCFC)
SetType(0x8015CCFC, "int DoSaveGame__Fv()")
del_items(0x8015CDBC)
SetType(0x8015CDBC, "void DoLoadGame__Fv()")
del_items(0x8015CE4C)
SetType(0x8015CE4C, "int DoFrontEndLoadCharacter__FPc(char *loadfilenameptr)")
del_items(0x8015CEA8)
SetType(0x8015CEA8, "void McInitLoadCard1Menu__Fv()")
del_items(0x8015CEF4)
SetType(0x8015CEF4, "void McInitLoadCard2Menu__Fv()")
del_items(0x8015CF40)
SetType(0x8015CF40, "void ChooseCardLoad__Fv()")
del_items(0x8015CFF4)
SetType(0x8015CFF4, "void McInitLoadCharMenu__Fv()")
del_items(0x8015D01C)
SetType(0x8015D01C, "void McInitLoadGameMenu__Fv()")
del_items(0x8015D078)
SetType(0x8015D078, "void McMainKeyCtrl__Fv()")
del_items(0x8015D234)
SetType(0x8015D234, "void ShowAlertBox__Fv()")
del_items(0x8015D3D4)
SetType(0x8015D3D4, "bool GetLoadStatusMessage__FPc(char *file_name)")
del_items(0x8015D478)
SetType(0x8015D478, "bool GetSaveStatusMessage__FiPc(int fileblocks, char *file_name)")
del_items(0x8015D550)
SetType(0x8015D550, "void SetRGB__6DialogUcUcUc(struct Dialog *this, unsigned char R, unsigned char G, unsigned char B)")
del_items(0x8015D570)
SetType(0x8015D570, "void SetBack__6Dialogi(struct Dialog *this, int Type)")
del_items(0x8015D578)
SetType(0x8015D578, "void SetBorder__6Dialogi(struct Dialog *this, int Type)")
del_items(0x8015D580)
SetType(0x8015D580, "int SetOTpos__6Dialogi(struct Dialog *this, int OT)")
del_items(0x8015D58C)
SetType(0x8015D58C, "void ___6Dialog_addr_8015D58C(struct Dialog *this, int __in_chrg)")
del_items(0x8015D5B4)
SetType(0x8015D5B4, "struct Dialog *__6Dialog_addr_8015D5B4(struct Dialog *this)")
del_items(0x8015D610)
SetType(0x8015D610, "int ILoad__Fv()")
del_items(0x8015D664)
SetType(0x8015D664, "void LoadQuest__Fi(int i)")
del_items(0x8015D72C)
SetType(0x8015D72C, "void ISave__Fi(int v)")
del_items(0x8015D78C)
SetType(0x8015D78C, "void SaveQuest__Fi(int i)")
del_items(0x8015D858)
SetType(0x8015D858, "int PSX_GM_SaveGame__FiPcT1(int card_number, char *name, char *title)")
del_items(0x8015DAE0)
SetType(0x8015DAE0, "int PSX_GM_LoadGame__FUcii(unsigned char firstflag, int card_number, int file)")
del_items(0x8015DDA0)
SetType(0x8015DDA0, "int PSX_CH_LoadGame__Fii(int card_number, int file)")
del_items(0x8015DF04)
SetType(0x8015DF04, "int PSX_CH_SaveGame__FiPcT1(int card_number, char *name, char *title)")
del_items(0x8015E09C)
SetType(0x8015E09C, "void RestorePads__Fv()")
del_items(0x8015E15C)
SetType(0x8015E15C, "void StorePads__Fv()")
del_items(0x8015E218)
SetType(0x8015E218, "void GetIcon__Fv()")
del_items(0x8015E254)
SetType(0x8015E254, "int PSX_OPT_LoadGame__Fiib(int card_number, int file, bool KillHandler)")
del_items(0x8015E2B8)
SetType(0x8015E2B8, "int PSX_OPT_SaveGame__FiPc(int card_number, char *filename)")
del_items(0x8015E350)
SetType(0x8015E350, "void LoadOptions__Fv()")
del_items(0x8015E3B0)
SetType(0x8015E3B0, "void SaveOptions__Fv()")
|
1680065
|
import databrewer
def test_package_metadata():
assert databrewer.__author__
assert databrewer.__email__
assert databrewer.__version__
|
1680123
|
from octopus.engine.explorer import Explorer
from requests.exceptions import ConnectionError as RequestsConnectionError
import json
EOS_DEFAULT_RPC_PORT = 8888
EOS_WALLET_RPC_PORT = 8889
class EosExplorer(Explorer):
"""
EOS REST RPC client class
doc: https://eosio.github.io/eos/group__eosiorpc.html
cleos source code: https://github.com/EOSIO/eos/blob/master/programs/cleos/main.cpp
"""
def __init__(self, host='localhost', port=EOS_DEFAULT_RPC_PORT, tls=False, max_retries=3):
Explorer.__init__(self, host=host, port=port, tls=tls, max_retries=max_retries)
def call(self, method, params={}, version='v1', api_type='chain'):
current_url = '{}/{}/{}/{}'.format(self.url, version, api_type, method)
try:
r = self.session.post(current_url, headers=self.headers, data=json.dumps(params))
except RequestsConnectionError:
raise Exception('RPC connection Error')
if not 200 <= r.status_code < 300:
raise Exception('RPC connection failure: ' + str(r.status_code) + ' ' + r.reason + ' ' + r.text)
try:
response = r.json()
except ValueError:
raise Exception('JSON response parsing error: ' + str(r.text))
try:
return response
except KeyError:
raise Exception('\"result\" field in JSON response error: ' + str(response))
##########################
# Chain API #
##########################
def get_info(self):
'''Get latest information related to a node
TESTED
'''
return self.call('get_info')
def get_block(self, block_num_or_id):
'''Get information related to a block.
TESTED
'''
data = {'block_num_or_id': block_num_or_id}
return self.call('get_block', data)
def get_raw_code_and_abi(self, account_name):
'''Fetch smart contract code.
TESTED
'''
data = {'account_name': account_name}
return self.call('get_raw_code_and_abi', data)
def get_account(self, account_name):
'''Get information related to an account.
TESTED
'''
data = {'account_name': account_name}
return self.call('get_account', data)
def get_code(self, account_name):
'''Fetch smart contract code.
TESTED
'''
data = {'account_name': account_name}
return self.call('get_code', data)
def get_table_rows(self, scope, code, table, json=False, lower_bound=None, upper_bound=None, limit=None):
'''Fetch smart contract data from an account.
NOT TESTED
'''
data = {'scope': scope,
'code': code,
'table': table,
'json': json}
if lower_bound:
data['lower_bound'] = lower_bound
if upper_bound:
data['upper_bound'] = upper_bound
if limit:
data['limit'] = limit
return self.call('get_table_rows', data)
def abi_json_to_bin(self, code, action, args):
'''Serialize json to binary hex. The resulting binary hex is usually used for the data field in push_transaction.
NOT TESTED
'''
data = {'code': code,
'action': action,
'args': args}
print(data)
return self.call('abi_json_to_bin', data)
def abi_bin_to_json(self, code, action, binargs):
'''Serialize back binary hex to json.
NOT TESTED
'''
data = {'code': code,
'action': action,
'binargs': binargs}
return self.call('abi_bin_to_json', data)
def push_transaction(self, tx_json):
'''This method expects a transaction in JSON format and will attempt to apply it to the blockchain,
NOT TESTED
'''
return self.call('push_transaction', tx_json)
def push_transactions(self, list_tx_json):
'''This method push multiple transactions at once.
NOT TESTED
'''
return self.call('push_transactions', list_tx_json)
def get_required_keys(self, transaction):
'''Get required keys to sign a transaction from list of your keys.
NOT TESTED
'''
data = {'transaction': transaction}
return self.call('get_required_keys', data)
##########################
# Wallet API #
##########################
def wallet_create(self, name):
'''Create a new wallet with the given name
TESTED
'''
return self.call('create', name, api_type='wallet')
def wallet_open(self, name):
'''Open an existing wallet of the given name
TESTED
'''
return self.call('open', name, api_type='wallet')
def wallet_lock(self, name):
'''Lock a wallet of the given name
TESTED
'''
return self.call('lock', name, api_type='wallet')
def wallet_lock_all(self):
'''Lock all wallets
TESTED
'''
return self.call('lock_all', api_type='wallet')
def wallet_unlock(self, name, password):
'''Unlock a wallet with the given name and password
TESTED
'''
return self.call('unlock', [name, password], api_type='wallet')
def wallet_import_key(self, name, priv_key):
'''Import a private key to the wallet of the given name
TESTED
'''
return self.call('import_key', [name, priv_key], api_type='wallet')
def wallet_list(self):
'''List all wallets
TESTED
'''
return self.call('list_wallets', api_type='wallet')
def wallet_list_keys(self):
'''List all key pairs across all wallets
TESTED
'''
return self.call('list_keys', api_type='wallet')
def wallet_get_public_keys(self):
'''List all public keys across all wallets
TESTED
'''
return self.call('get_public_keys', api_type='wallet')
def wallet_set_timeout(self, timeout_s):
'''Set wallet auto lock timeout (in seconds)
TESTED
'''
return self.call('set_timeout', timeout_s, api_type='wallet')
def wallet_sign_trx(self, tx_json):
'''Sign transaction given an array of transaction, require public keys, and chain id
NOT TESTED
'''
return self.call('sign_transaction', tx_json)
|
1680151
|
from brownie import *
import time
import json
import csv
import math
def main():
thisNetwork = network.show_active()
# == Load config =======================================================================================================================
if thisNetwork == "development":
acct = accounts[0]
configFile = open('./scripts/contractInteraction/testnet_contracts.json')
elif thisNetwork == "testnet":
acct = accounts.load("rskdeployer")
configFile = open('./scripts/contractInteraction/testnet_contracts.json')
elif thisNetwork == "rsk-mainnet":
acct = accounts.load("rskdeployer")
configFile = open('./scripts/contractInteraction/mainnet_contracts.json')
else:
raise Exception("network not supported")
# load deployed contracts addresses
contracts = json.load(configFile)
vestingRegistry = Contract.from_abi("VestingRegistry", address=contracts['VestingRegistry'], abi=VestingRegistry.abi, owner=acct)
staking = Contract.from_abi("Staking", address=contracts['Staking'], abi=Staking.abi, owner=acct)
SOVtoken = Contract.from_abi("SOV", address=contracts['SOV'], abi=SOV.abi, owner=acct)
DAY = 24 * 60 * 60
FOUR_WEEKS = 4 * 7 * DAY
balanceBefore = acct.balance()
totalAmount = 0
# amounts examples: 3787.24, 627.22
data = parseFile('./scripts/deployment/distribution/vestings4-bug-bounty.csv', 10**16)
totalAmount += data["totalAmount"]
for teamVesting in data["teamVestingList"]:
tokenOwner = teamVesting[0]
amount = int(teamVesting[1])
cliff = int(teamVesting[2]) * FOUR_WEEKS
duration = int(teamVesting[3]) * FOUR_WEEKS
isTeam = bool(teamVesting[4])
if isTeam:
vestingAddress = vestingRegistry.getTeamVesting(tokenOwner)
else:
vestingAddress = vestingRegistry.getVesting(tokenOwner)
if (vestingAddress != "0x0000000000000000000000000000000000000000"):
vestingLogic = Contract.from_abi("VestingLogic", address=vestingAddress, abi=VestingLogic.abi, owner=acct)
if (cliff != vestingLogic.cliff() or duration != vestingLogic.duration()):
raise Exception("Address already has team vesting contract with different schedule")
print("=======================================")
if isTeam:
# vestingRegistry.createTeamVesting(tokenOwner, amount, cliff, duration)
# vestingAddress = vestingRegistry.getTeamVesting(tokenOwner)
print("TeamVesting: ", vestingAddress)
else:
# vestingRegistry.createVesting(tokenOwner, amount, cliff, duration)
# vestingAddress = vestingRegistry.getVesting(tokenOwner)
print("Vesting: ", vestingAddress)
print(tokenOwner)
print(isTeam)
print(amount)
print(cliff)
print(duration)
print((duration - cliff) / FOUR_WEEKS + 1)
# SOVtoken.approve(vestingAddress, amount)
# vestingLogic = Contract.from_abi("VestingLogic", address=vestingAddress, abi=VestingLogic.abi, owner=acct)
# vestingLogic.stakeTokens(amount)
# stakes = staking.getStakes(vestingAddress)
# print(stakes)
# 5825.7
print("=======================================")
print("SOV amount:")
print(totalAmount / 10**18)
print("deployment cost:")
print((balanceBefore - acct.balance()) / 10**18)
def parseFile(fileName, multiplier):
print(fileName)
totalAmount = 0
teamVestingList = []
with open(fileName, 'r') as file:
reader = csv.reader(file)
for row in reader:
tokenOwner = row[1].replace(" ", "")
amount = row[0].replace(",", "").replace(".", "")
amount = int(amount) * multiplier
cliff = int(row[3])
duration = int(row[4])
isTeam = True
if (row[5] == "OwnerVesting"):
isTeam = False
totalAmount += amount
teamVestingList.append([tokenOwner, amount, cliff, duration, isTeam])
# print("=======================================")
# print("'" + tokenOwner + "', ")
# print(amount)
return {
"totalAmount": totalAmount,
"teamVestingList": teamVestingList,
}
|
1680164
|
from model import MusicVAE
from loader import load_noteseqs
import numpy as np
import tensorflow as tf
import argparse
tf.reset_default_graph()
ap = argparse.ArgumentParser()
ap.add_argument("-bs", "--batch_size", default=32, type=int)
ap.add_argument("-s", "--save_path", default="vae/", type=str)
ap.add_argument("-e", "--epochs", default=100, type=int)
ap.add_argument("--train_set", default="data/Jsbtr.pkl data/Nmdtr.pkl", type=str)
ap.add_argument("--test_set", default="data/Jsbte.pkl data/Nmdte.pkl", type=str)
ap.add_argument("--x_depth", default="89 33 33", type=str)
ap.add_argument("--enc_rnn", default="hyperlstm", type=str)
ap.add_argument("--enc_rnn_dim", default=512, type=int)
ap.add_argument("--enc_hyper_unit", default=256, type=int)
ap.add_argument("--enc_dropout", default=0.25, type=float)
ap.add_argument("--enc_rnn_layer", default=1, type=int)
ap.add_argument("--dec_rnn", default="hyperlstm", type=str)
ap.add_argument("--dec_rnn_dim", default=512, type=int)
ap.add_argument("--dec_hyper_unit", default=256, type=int)
ap.add_argument("--dec_dropout", default=0.25, type=float)
ap.add_argument("--dec_rnn_layer", default=1, type=int)
ap.add_argument("--attention", default=128, type=int)
ap.add_argument("--cont_dim", default=100, type=int)
ap.add_argument("--cat_dim", default=2, type=int)
ap.add_argument("--style_embed_dim", default=100, type=int)
ap.add_argument("--mu_force", default=2.0, type=float)
ap.add_argument("--gumbel", default=0.67, type=float)
ap.add_argument("--kl_reg", default=1.0, type=float)
ap.add_argument("--kl_anneal", default=1000, type=int)
ap.add_argument("--restore_path", default=None, type=str)
args = ap.parse_args()
x_depth = args.x_depth.split()
x_depth = [int(i) for i in x_depth]
train_set = args.train_set.split()
test_set = args.test_set.split()
train_graph = tf.Graph()
val_graph = tf.Graph()
with train_graph.as_default():
t_it, t_x, t_s, t_l = load_noteseqs(train_set, x_depth,
batch_size=args.batch_size, augment=True).get_iterator()
m = MusicVAE(x_depth=x_depth,
enc_rnn_dim=args.enc_rnn_dim, enc_hyper_unit=args.enc_hyper_unit, enc_dropout=args.enc_dropout,
dec_rnn_dim=args.dec_rnn_dim, dec_hyper_unit=args.dec_hyper_unit, dec_dropout=args.dec_dropout,
enc_rnn_layer=args.enc_rnn_layer, dec_rnn_layer=args.dec_rnn_layer,
enc_rnn=args.enc_rnn, dec_rnn=args.dec_rnn,
attention=args.attention,
cont_dim=args.cont_dim, cat_dim=args.cat_dim, mu_force=args.mu_force,
gumbel=args.gumbel, style_embed_dim=args.style_embed_dim,
kl_reg=args.kl_reg,
training=True, beta_anneal_steps=args.kl_anneal)
m.build(t_x, t_s, t_l, None)
with val_graph.as_default():
v_it, v_x, v_s, v_l = load_noteseqs(test_set, x_depth,
batch_size=20).get_iterator()
n = MusicVAE(x_depth=x_depth,
enc_rnn_dim=args.enc_rnn_dim, enc_hyper_unit=args.enc_hyper_unit, enc_dropout=0.0,
dec_rnn_dim=args.dec_rnn_dim, dec_hyper_unit=args.dec_hyper_unit, dec_dropout=0.0,
enc_rnn_layer=args.enc_rnn_layer, dec_rnn_layer=args.dec_rnn_layer,
enc_rnn=args.enc_rnn, dec_rnn=args.dec_rnn,
attention=args.attention,
cont_dim=args.cont_dim, cat_dim=args.cat_dim, mu_force=args.mu_force,
gumbel=args.gumbel, style_embed_dim=args.style_embed_dim,
kl_reg=args.kl_reg,
training=False, beta_anneal_steps=args.kl_anneal)
n.build(v_x, v_s, v_l, None)
tf_config = tf.ConfigProto()
tf_config.allow_soft_placement = True
tf_config.gpu_options.allow_growth = True
sess = tf.Session(config=tf_config, graph=train_graph)
ss = tf.Session(config=tf_config, graph=val_graph)
if args.restore_path:
print("[INFO] Restoring from checkpoint {}".format(args.restore_path))
m.saver.restore(sess, args.restore_path)
else:
sess.run(m.init)
step = 0
tw = tf.summary.FileWriter(args.save_path+"train", sess.graph)
vw = tf.summary.FileWriter(args.save_path+"val", ss.graph)
print("[INFO] Start training...")
for epoch in range(args.epochs):
sess.run(t_it.initializer)
train_loss = []
train_kl = []
while True:
try:
if (step+1)%20 == 0 or step == 0:
_, tmp_loss, tmp_kl, step, summ = sess.run([m.op, m.recon_loss, m.kl_loss, m.step, m.summ_op])
tw.add_summary(summ, step)
else:
_, tmp_loss, tmp_kl, step = sess.run([m.op, m.recon_loss, m.kl_loss, m.step])
train_loss.append(tmp_loss)
train_kl.append(tmp_kl)
except tf.errors.OutOfRangeError:
break
m.saver.save(sess, args.save_path + "vae-epoch{}".format(epoch+1))
n.saver.restore(ss, args.save_path + "vae-epoch{}".format(epoch+1))
val_loss = []
val_kl = []
ss.run(v_it.initializer)
while True:
try:
tmp_loss, tmp_kl, summ = ss.run([n.recon_loss, n.kl_loss, n.summ_op])
val_loss.append(tmp_loss)
val_kl.append(tmp_kl)
except tf.errors.OutOfRangeError:
vw.add_summary(summ, step)
break
train_loss = np.mean(train_loss)
train_kl = np.mean(train_kl)
val_loss = np.mean(val_loss)
val_kl = np.mean(val_kl)
print("{} Train Loss: {:.4f} Train KL: {:.2f} Val Loss: {:.4f} Val KL: {:.2f}".format(epoch+1, train_loss, train_kl, val_loss, val_kl))
|
1680172
|
from django.apps import AppConfig
class DemandsConfig(AppConfig):
name = 'demands'
def ready(self):
import demands.signals
super(DemandsConfig, self).ready()
|
1680175
|
from unittest import TestCase
import utils
from mock import patch
from mock import mock_open
from textwrap import dedent
from collections import namedtuple
from argparse import Namespace
class TestUtils(TestCase):
@patch('builtins.exit')
@patch('os.path.isfile')
def test_check_for_files_file_not_existing(self, m_isfile, m_exit):
m_isfile.return_value = False
utils.check_for_file('file.txt')
self.assertTrue(m_exit.called)
@patch('builtins.exit')
@patch('os.path.isfile')
def test_check_for_files_file_exists(self, m_isfile, m_exit):
m_isfile.return_value = True
utils.check_for_file('file.txt')
self.assertFalse(m_exit.called)
@patch('os.path.isfile', lambda path: True)
def test_read(self):
data = dedent("""
int,float,string
1,45.5,node-1
""").strip()
m = mock_open(read_data=data)
m.return_value.__iter__ = lambda self: self
m.return_value.__next__ = lambda self: next(iter(self.readline, ''))
with patch('builtins.open', m):
data = utils.read_csv('/some.csv')[0]
self.assertEqual(data.int, 1)
self.assertEqual(data.float, 45.5)
self.assertEqual(data.string, 'node-1')
def test_read_empty_file(self):
m = mock_open(read_data='')
m.return_value.__iter__ = lambda self: self
m.return_value.__next__ = lambda self: next(iter(self.readline, ''))
with patch('builtins.open', m):
data = utils.read_csv('/some.csv')
self.assertEqual(data, [])
@patch('utils.read_csv', lambda file: [])
@patch('builtins.open', new_callable=mock_open)
def test_update_args_1(self, m_open):
utils.update_args(Namespace(int=1, float=1.1, string='test'))
handle = m_open()
self.assertEqual(handle.write.call_count, 2)
self.assertIn('string', handle.write.call_args_list[0][0][0])
self.assertIn('float', handle.write.call_args_list[0][0][0])
self.assertIn('int', handle.write.call_args_list[0][0][0])
self.assertIn('1', handle.write.call_args_list[1][0][0])
self.assertIn('1.1', handle.write.call_args_list[1][0][0])
self.assertIn('test', handle.write.call_args_list[1][0][0])
@patch('utils.read_csv')
@patch('builtins.open', new_callable=mock_open)
def test_update_args_2(self, m_open, m_read):
Args = namedtuple('Args', 'int float')
m_read.return_value = [Args(2, 2.2)]
utils.update_args(Namespace(int=1, string='test'))
handle = m_open()
self.assertEqual(handle.write.call_count, 2)
self.assertIn('1', handle.write.call_args_list[1][0][0])
self.assertIn('2.2', handle.write.call_args_list[1][0][0])
self.assertIn('test', handle.write.call_args_list[1][0][0])
|
1680216
|
from gpiozero import LED
from time import sleep
red = LED(21, active_high=False)
# while True:
red.on()
print('on')
sleep(30)
# red.off()
# print('off')
# sleep(4)
|
1680224
|
import os
import sys
import click
from ftcli.Lib.Font import Font
from ftcli.Lib.utils import getFontsList, makeOutputFileName, guessFamilyName
@click.group()
def setLineGap():
pass
@setLineGap.command()
@click.argument('input_path', type=click.Path(exists=True, resolve_path=True))
@click.option('-p', '--percent', type=click.IntRange(1, 100), required=True,
help="adjust font line spacing to % of UPM value")
@click.option('-mfn', '--modify-family-name', is_flag=True,
help="adds 'LG% to the font family to reflect the modified line gap'")
@click.option('-o', '--output-dir', type=click.Path(file_okay=False, resolve_path=True),
help='The output directory where the output files are to be created. If it doesn\'t exist, will be '
'created. If not specified, files are saved to the same folder.')
@click.option('--recalc-timestamp/--no-recalc-timestamp', default=False,
help='Keeps the original font \'modified\' timestamp (head.modified) or set it to current time. '
'By default, original timestamp is kept.')
@click.option('--overwrite/--no-overwrite', default=True,
help='Overwrites existing output files or save them to a new file (numbers are appended at the end of '
'file name). By default, files are overwritten.')
def set_linegap(input_path, percent, modify_family_name, output_dir, recalc_timestamp, overwrite):
"""Modifies the line spacing metrics in one or more fonts.
TThis is a CLI for font-line by Source Foundry: https://github.com/source-foundry/font-line
"""
files = getFontsList(input_path)
for f in files:
file_name, ext = os.path.splitext(os.path.basename(f))
file_dir = os.path.dirname(f)
try:
font = Font(f, recalcTimestamp=recalc_timestamp)
font.modifyLinegapPercent(percent)
# Modify the family name according to the linegap percent
if modify_family_name:
old_family_name = guessFamilyName(font)
if old_family_name:
old_family_name_without_spaces = old_family_name.replace(" ", "")
new_family_name = old_family_name + ' LG{}'.format(str(percent))
new_family_name_without_spaces = new_family_name.replace(" ", "")
font.findReplace(oldString=old_family_name, newString=new_family_name, fixCFF=True)
font.findReplace(oldString=old_family_name_without_spaces, newString=new_family_name_without_spaces,
fixCFF=True)
else:
click.secho('Warning: could not retrieve Family Name, it has not been modified.', fg='yellow')
# Before we add the "-linegap%" string to the new file name, let's remove it to avoid strange names like
# Font-Bold-linegap20-linegap20.otf
new_file_path = os.path.join(file_dir, file_name.replace('-linegap' + str(percent), '') + '-linegap'
+ str(percent) + ext)
output_file = makeOutputFileName(new_file_path, outputDir=output_dir, overWrite=overwrite)
font.save(output_file)
click.secho(f'{os.path.basename(output_file)} --> saved', fg='green')
except Exception as e:
click.secho(f'ERROR: {e}', fg='red')
@click.group()
def alignVMetrics():
pass
@alignVMetrics.command()
@click.argument('input_path', type=click.Path(exists=True, file_okay=False, resolve_path=True))
@click.option('-sil', '--sil-method', is_flag=True, help='Use SIL method: '
'http://silnrsi.github.io/FDBP/en-US/Line_Metrics.html')
@click.option('-o', '--output-dir', type=click.Path(file_okay=False, resolve_path=True),
help='The output directory where the output files are to be created. If it doesn\'t exist, will be '
'created. If not specified, files are saved to the same folder.')
@click.option('--recalc-timestamp/--no-recalc-timestamp', default=False,
help='Keeps the original font \'modified\' timestamp (head.modified) or set it to current time. '
'By default, original timestamp is kept.')
@click.option('--overwrite/--no-overwrite', default=True,
help='Overwrites existing output files or save them to a new file (numbers are appended at the end of '
'file name). By default, files are overwritten.')
def align(input_path, sil_method, output_dir, recalc_timestamp, overwrite):
"""
Aligns all fonts in INPUT_PATH to the same baseline.
To achieve this, the script finds the maximum ascender and the minimum descender values of the fonts stored in the
INPUT_PATH folder and applies those values to all fonts.
This can produce undesired effects (an exaggerated line height) when one or more fonts contain swashes, for example.
In such cases, it's better to copy the vertical metrics from a template font to one or more destination fonts using
the 'ftcli metrics copy' command.
See https://www.kltf.de/downloads/FontMetrics-kltf.pdf for more information.
"""
files = getFontsList(input_path)
idealAscenders = []
idealDescenders = []
realAscenders = []
realDescenders = []
for f in files:
try:
font = Font(f, recalcTimestamp=recalc_timestamp)
yMax = font['head'].yMax
yMin = font['head'].yMin
ascender = font['hhea'].ascender
descender = font['hhea'].descender
sTypoAscender = font['OS/2'].sTypoAscender
sTypoDescender = font['OS/2'].sTypoDescender
usWinAscent = font['OS/2'].usWinAscent
usWinDescent = font['OS/2'].usWinDescent
idealAscenders.extend([sTypoAscender])
idealDescenders.extend([abs(sTypoDescender)])
realAscenders.extend([yMax, usWinAscent, ascender])
realDescenders.extend(
[abs(yMin), abs(usWinDescent), abs(descender)])
except Exception as e:
click.secho('ERROR: {}'.format(e), fg='red')
files.remove(f)
maxRealAscender = max(realAscenders)
maxRealDescender = max(realDescenders)
maxIdealAscender = max(idealAscenders)
maxIdealDescender = max(idealDescenders)
sTypoLineGap = (maxRealAscender + maxRealDescender) - (maxIdealAscender + maxIdealDescender)
sTypoLineGap = 0
for f in files:
try:
font = Font(f, recalcTimestamp=recalc_timestamp)
font['hhea'].ascender = maxRealAscender
font['hhea'].descender = -maxRealDescender
font['hhea'].lineGap = 0
font['OS/2'].usWinAscent = maxRealAscender
font['OS/2'].usWinDescent = maxRealDescender
font['OS/2'].sTypoAscender = maxIdealAscender
font['OS/2'].sTypoDescender = -maxIdealDescender
font['OS/2'].sTypoLineGap = sTypoLineGap
if sil_method:
font['OS/2'].sTypoAscender = maxRealAscender
font['OS/2'].sTypoDescender = -maxRealDescender
font['OS/2'].sTypoLineGap = 0
output_file = makeOutputFileName(
f, outputDir=output_dir, overWrite=overwrite)
font.save(output_file)
click.secho(f'{os.path.basename(output_file)} --> saved', fg='green')
except Exception as e:
click.secho(f'ERROR: {e}', fg='red')
@click.group()
def copyVMetrics():
pass
@copyVMetrics.command()
@click.option('-s', '--source-file', type=click.Path(exists=True, dir_okay=False, resolve_path=True), required=True,
help='Source file. Vertical metrics from this font will be applied to all destination fonts.')
@click.option('-d', '--destination', type=click.Path(exists=True, resolve_path=True), required=True,
help='Destination file or directory')
@click.option('-o', '--output-dir', type=click.Path(file_okay=False, resolve_path=True),
help='The output directory where the output files are to be created. If it doesn\'t exist, will be '
'created. If not specified, files are saved to the same folder.')
@click.option('--recalc-timestamp/--no-recalc-timestamp', default=False,
help='Keeps the original font \'modified\' timestamp (head.modified) or set it to current time. By '
'default, original timestamp is kept.')
@click.option('--overwrite/--no-overwrite', default=True,
help='Overwrites existing output files or save them to a new file (numbers are appended at the end of '
'file name). By default, files are overwritten.')
def copy(source_file, destination, output_dir, recalc_timestamp, overwrite):
"""
Copies vertical metrics from a source font to one or more destination fonts.
"""
try:
source_font = Font(source_file)
ascender = source_font['hhea'].ascender
descender = source_font['hhea'].descender
usWinAscent = source_font['OS/2'].usWinAscent
usWinDescent = source_font['OS/2'].usWinDescent
sTypoAscender = source_font['OS/2'].sTypoAscender
sTypoDescender = source_font['OS/2'].sTypoDescender
sTypoLineGap = source_font['OS/2'].sTypoLineGap
except Exception as e:
click.secho('ERROR: {}'.format(e), fg='red')
sys.exit()
files = getFontsList(destination)
for f in files:
try:
font = Font(f, recalcTimestamp=recalc_timestamp)
font['hhea'].ascender = ascender
font['hhea'].descender = descender
font['hhea'].lineGap = 0
font['OS/2'].usWinAscent = usWinAscent
font['OS/2'].usWinDescent = usWinDescent
font['OS/2'].sTypoAscender = sTypoAscender
font['OS/2'].sTypoDescender = sTypoDescender
font['OS/2'].sTypoLineGap = sTypoLineGap
output_file = makeOutputFileName(
f, outputDir=output_dir, overWrite=overwrite)
font.save(output_file)
click.secho(f'{os.path.basename(output_file)} --> saved', fg='green')
except Exception as e:
click.secho(f'ERROR: {e}', fg='red')
cli = click.CommandCollection(sources=[alignVMetrics, copyVMetrics, setLineGap], help="""
Aligns all the fonts to the same baseline.
The 'ftcli metrics align' command calculates the maximum ascenders and descenders of a set of fonts and applies them to
all fonts in that set.
The 'ftcli metrics copy' command copies vertical metrics from a source font to one or more destination fonts.
"""
)
|
1680231
|
Compare two version numbers version1 and version2.
If version1 > version2 return 1, if version1 < version2 return -1, otherwise return 0.
You may assume that the version strings are non-empty and contain only digits and the . character.
The . character does not represent a decimal point and is used to separate number sequences.
For instance, 2.5 is not "two and a half" or "half way to version three", it is the fifth second-level revision of the second first-level revision.
Here is an example of version numbers ordering:
0.1 < 1.1 < 1.2 < 13.37
# https://leetcode.com/discuss/45331/2-4-lines-python-3-different-ways
def compareVersion(self, version1, version2):
v1, v2 = (map(int, v.split('.')) for v in (version1, version2))
d = len(v2) - len(v1)
return cmp(v1 + [0]*d, v2 + [0]*-d)
class Solution:
# @param version1, a string
# @param version2, a string
# @return an integer
def compareVersion(self, version1, version2):
str_ver1 = version1.split('.')
str_ver2 = version2.split('.')
for i in xrange(min(len(str_ver1),len(str_ver2))):
if int(str_ver1[i]) > int(str_ver2[i]): # Need to transfer the string to the integer
return 1
elif int(str_ver1[i]) < int(str_ver2[i]):
return -1
if len(str_ver1) > len(str_ver2): # Note: we should seperate the if condition here !
if all(int(num) == 0 for num in str_ver1[i+1:]): # Note: here we should use i+1 instead of i
return 0
else:
return 1
if len(str_ver1) < len(str_ver2):
if all( int(num) == 0 for num in str_ver2[i+1:]): # Note: here we should use i+1 instead of i
return 0
else:
return -1
if len(str_ver1) == len(str_ver2): return 0
# Note: in-build function all() usage
'''
all(iterable)
Return True if all elements of the iterable are true (or if the iterable is empty). Equivalent to:
def all(iterable):
for element in iterable:
if not element:
return False
return True
'''
# 几个corner case需要考虑,第一个版本后面跟0的时候,1.0和1.00
# 需要将string转换为integer
|
1680254
|
import unittest
from copy import deepcopy
import numpy as np
import torch
import torch.nn as nn
import torchvision
from code_soup.ch5 import ZooAttack
class TestZooAttack(unittest.TestCase):
@classmethod
def setUpClass(cls) -> None:
cls.orig_img = torch.tensor(
[
[
[
[-1.6505998, -1.0305759, 1.0229983],
[-0.49261865, 1.0394262, -2.0290275],
[0.21951008, -2.1673787, -0.38990623],
[-0.2866124, 1.0799991, -0.11442444],
],
[
[-0.7052935, -0.5529446, 0.26524046],
[-1.0540642, 0.6887131, 1.6723113],
[1.1097006, 2.1335971, 0.9231482],
[0.37910375, -0.12366215, -0.25093704],
],
[
[-1.9404864, -1.3078933, 0.88476175],
[0.35099706, -1.254437, 0.05408821],
[0.7342985, -0.43663985, 0.11520719],
[-0.07479854, -2.5859993, 1.4102333],
],
[
[0.21304935, -0.3496548, -0.19856042],
[-0.434919, -0.27774376, 1.1471609],
[1.4504786, 0.67261624, -0.23560882],
[1.0592173, 0.6655428, 1.1890292],
],
]
],
dtype=torch.float32,
)
cls.modifier = np.array(
[
[
[
[-0.21563086, 0.54629284, 1.0879989],
[-0.17234534, 0.37302095, 1.5072422],
[-0.14709516, -0.08446954, -1.0199878],
[-0.46581882, 0.41346493, -1.6357177],
],
[
[0.97039294, -0.46038368, -0.5377948],
[-0.08285582, -1.4017423, -0.6447743],
[-0.6031785, -2.003339, -0.01103557],
[0.41714168, -1.94303, 0.6685426],
],
[
[-0.83851266, 0.79823476, 0.2532903],
[-0.76351106, 0.90984505, 1.331635],
[-1.1300149, -0.8444777, -2.2185612],
[1.0166003, 0.9233805, 0.98315567],
],
[
[-0.88205546, -0.3438152, -0.36559045],
[0.56274384, 1.5836877, -1.2370849],
[1.4234338, -0.5929535, -1.3011148],
[0.84160084, 0.90161383, 0.80880517],
],
]
],
dtype=np.float32,
)
cls.labels = torch.tensor([[0, 1]])
cls.config = {
"binary_search_steps": 1,
"max_iterations": 100,
"learning_rate": 2e-3,
"abort_early": True,
"targeted": True,
"confidence": 0,
"initial_const": 0.5,
"use_log": False,
"use_tanh": True,
"reset_adam_after_found": True,
"batch_size": 4,
"const": 0.5,
"early_stop_iters": 0,
"adam_beta1": 0.9,
"adam_beta2": 0.999,
"use_importance": True,
"use_resize": False,
"init_size": 4,
"adam_eps": 1e-8,
"resize_iter_1": 2000,
"resize_iter_2": 10000,
}
cls.model = nn.Sequential(
nn.Conv2d(
in_channels=3, out_channels=1, kernel_size=2, padding=0, bias=False
),
nn.Flatten(),
nn.Linear(4 * 4 * 3, 2, bias=False),
)
with torch.no_grad():
cls.model[0].weight = nn.Parameter(
torch.tensor(
[
[
[[0.18992287], [-0.6111586], [-0.41560256]],
[[0.19819254], [0.06157357], [-0.29873127]],
],
[
[[0.08528781], [-0.4988662], [0.51414317]],
[[0.5520558], [0.35638297], [0.29052997]],
],
]
).permute(3, 2, 0, 1)
)
cls.model[2].weight = nn.Parameter(
torch.tensor(
[
[0.26311237, 0.7238547],
[-0.2869757, -0.6140047],
[-0.11846703, -0.57517225],
[-0.72543985, 0.6393444],
[0.45188862, 0.35718697],
[-0.7197881, 0.17988789],
[0.18161213, 0.32464463],
[0.37511164, 0.07291293],
[-0.27989575, -0.37013885],
]
).T
)
cls.attack = ZooAttack(
model=cls.model,
config=cls.config,
input_image_shape=cls.orig_img.shape[1:],
device="cpu:0",
)
def test_get_perturbed_image(self):
perturbed_image = self.attack.get_perturbed_image(self.orig_img, self.modifier)
self.assertEqual(perturbed_image.shape, self.orig_img.shape)
output = torch.tanh(self.orig_img + self.modifier) / 2
self.assertTrue(torch.allclose(perturbed_image, output, atol=1e-5))
# Without Tanh
attack = deepcopy(self.attack)
attack.config["use_tanh"] = False
perturbed_image_2 = attack.get_perturbed_image(self.orig_img, self.modifier)
self.assertEqual(perturbed_image_2.shape, self.orig_img.shape)
output_2 = self.orig_img + torch.from_numpy(self.modifier)
self.assertTrue(torch.allclose(perturbed_image_2, output_2, atol=1e-5))
# Integration Test
self.assertTrue(
torch.allclose(
perturbed_image,
torch.tensor(
[
[
[-0.47662562, -0.22483358, 0.4855427],
[-0.2908287, 0.44400635, -0.23953833],
[0.0361443, -0.4890532, -0.44373578],
[-0.3182986, 0.45198008, -0.47069582],
],
[
[0.12952949, -0.38356757, -0.13300003],
[-0.4066872, -0.30628642, 0.38645932],
[0.23361546, 0.06476317, 0.36107236],
[0.33096626, -0.48422426, 0.19745564],
],
[
[-0.49615836, -0.23483951, 0.40687856],
[-0.19530259, -0.16578534, 0.44111317],
[-0.18813889, -0.42839125, -0.4853233],
[0.3680245, -0.46528453, 0.49172965],
],
[
[-0.2921629, -0.3001033, -0.25552535],
[0.06356658, 0.43162277, -0.04484118],
[0.49682045, 0.03974732, -0.4557841],
[0.4781537, 0.4582861, 0.4819371],
],
],
),
)
)
def test_l2_distance_loss(self):
new_img = self.attack.get_perturbed_image(self.orig_img, self.modifier)
loss = self.attack.l2_distance_loss(self.orig_img, new_img)
self.assertEqual(loss.shape[0], self.orig_img.shape[0])
# Without Tanh
attack = deepcopy(self.attack)
attack.config["use_tanh"] = False
new_img_2 = attack.get_perturbed_image(self.orig_img, self.modifier)
loss_2 = attack.l2_distance_loss(self.orig_img, new_img_2)
self.assertEqual(loss_2.shape[0], self.orig_img.shape[0])
# Integration Test
self.assertTrue(np.allclose(np.array([3.7336116]), loss, atol=1e-5))
def test_confidence_loss(self):
new_img = self.attack.get_perturbed_image(self.orig_img, self.modifier)
loss, model_output = self.attack.confidence_loss(new_img, self.labels)
self.assertEqual(loss.shape[0], new_img.shape[0])
# With Log and Untargeted
attack = deepcopy(self.attack)
attack.config["use_log"] = True
attack.config["targeted"] = False
new_img_2 = attack.get_perturbed_image(self.orig_img, self.modifier)
loss_2, model_output = attack.confidence_loss(new_img_2, self.labels)
self.assertEqual(loss_2.shape[0], new_img_2.shape[0])
# Integration Test
self.assertTrue(np.allclose(np.array([0.2148518]), loss, atol=1e-5))
def test_zero_order_gradients(self):
losses = np.random.randn(2 * self.config["batch_size"] + 1)
grads = self.attack.zero_order_gradients(losses)
self.assertEqual(grads.shape, (self.config["batch_size"],))
def test_total_loss(self):
new_img = self.attack.get_perturbed_image(self.orig_img, self.modifier)
loss, l2_loss, confidence_loss, model_output = self.attack.total_loss(
self.orig_img, new_img, self.labels, self.config["initial_const"]
)
self.assertEqual(loss.shape[0], self.orig_img.shape[0])
self.assertEqual(confidence_loss.shape[0], self.orig_img.shape[0])
self.assertEqual(l2_loss.shape[0], self.orig_img.shape[0])
self.assertEqual(model_output.shape, self.labels.shape)
def test_max_pooling(self):
modifier = self.modifier[0][:, :, 0]
pooled_output = self.attack.max_pooling(modifier, 2)
self.assertEqual(pooled_output.shape, modifier.shape)
# Integration Test
self.assertTrue(
np.allclose(
pooled_output,
np.array(
[
[
0.97039294,
0.97039294,
0.41714168,
0.41714168,
],
[
0.97039294,
0.97039294,
0.41714168,
0.41714168,
],
[
0.56274384,
0.56274384,
1.4234338,
1.4234338,
],
[
0.56274384,
0.56274384,
1.4234338,
1.4234338,
],
]
),
atol=1e-5,
)
)
def test_coordinate_adam(self):
# With Proj True
attack = deepcopy(self.attack)
attack.config["use_tanh"] = False
attack.up = 0.5 - self.orig_img.numpy().reshape(-1)
attack.down = -0.5 - self.orig_img.numpy().reshape(-1)
indices = np.array([15, 24, 32, 45])
grad = np.array([2000.0, 3500.0, -1000.0, -1500.0])
proj = not attack.config["use_tanh"]
modifier = deepcopy(self.modifier)
attack.coordinate_adam(indices, grad, modifier, proj)
self.assertTrue(
np.allclose(
attack.mt_arr,
np.array(
[
0.0,
0.0,
0.0,
0.0,
0.0,
0.0,
0.0,
0.0,
0.0,
0.0,
0.0,
0.0,
0.0,
0.0,
0.0,
200.0,
0.0,
0.0,
0.0,
0.0,
0.0,
0.0,
0.0,
0.0,
350.0,
0.0,
0.0,
0.0,
0.0,
0.0,
0.0,
0.0,
-100.0,
0.0,
0.0,
0.0,
0.0,
0.0,
0.0,
0.0,
0.0,
0.0,
0.0,
0.0,
0.0,
-150.0,
0.0,
0.0,
],
),
atol=1e-5,
)
)
self.assertTrue(
np.allclose(
attack.vt_arr,
np.array(
[
0.0,
0.0,
0.0,
0.0,
0.0,
0.0,
0.0,
0.0,
0.0,
0.0,
0.0,
0.0,
0.0,
0.0,
0.0,
4000.0,
0.0,
0.0,
0.0,
0.0,
0.0,
0.0,
0.0,
0.0,
12250.0,
0.0,
0.0,
0.0,
0.0,
0.0,
0.0,
0.0,
1000.0,
0.0,
0.0,
0.0,
0.0,
0.0,
0.0,
0.0,
0.0,
0.0,
0.0,
0.0,
0.0,
2250.0,
0.0,
0.0,
],
),
atol=1e-5,
)
)
self.assertTrue(
np.allclose(
modifier,
np.array(
[
[
[-0.21563086, 0.54629284, 1.0879989],
[-0.17234534, 0.37302095, 1.5072422],
[-0.14709516, -0.08446954, -1.0199878],
[-0.46581882, 0.41346493, -1.6357177],
],
[
[0.97039294, -0.46038368, -0.5377948],
[0.55406415, -1.4017423, -0.6447743],
[-0.6031785, -2.003339, -0.01103557],
[0.41714168, -1.94303, 0.6685426],
],
[
[1.4404864, 0.79823476, 0.2532903],
[-0.76351106, 0.90984505, 1.331635],
[-1.1300149, -0.8444777, -0.6152072],
[1.0166003, 0.9233805, 0.98315567],
],
[
[-0.88205546, -0.3438152, -0.36559045],
[0.56274384, 1.5836877, -1.2370849],
[1.4234338, -0.5929535, -1.3011148],
[-0.55921733, 0.90161383, 0.80880517],
],
]
),
atol=1e-5,
)
)
self.assertTrue(
(
attack.adam_epochs
== np.array(
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
2,
1,
1,
1,
1,
1,
1,
1,
1,
2,
1,
1,
1,
1,
1,
1,
1,
2,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
2,
1,
1,
],
)
).all(),
)
# Integration Test
# Without Proj True
attack = deepcopy(self.attack)
indices = np.array([15, 24, 32, 45])
grad = np.array([2000.0, 3500.0, -1000.0, -1500.0])
proj = not attack.config["use_tanh"]
modifier = deepcopy(self.modifier)
attack.coordinate_adam(indices, grad, modifier, proj)
self.assertTrue(
np.allclose(
attack.mt_arr,
np.array(
[
0.0,
0.0,
0.0,
0.0,
0.0,
0.0,
0.0,
0.0,
0.0,
0.0,
0.0,
0.0,
0.0,
0.0,
0.0,
200.0,
0.0,
0.0,
0.0,
0.0,
0.0,
0.0,
0.0,
0.0,
350.0,
0.0,
0.0,
0.0,
0.0,
0.0,
0.0,
0.0,
-100.0,
0.0,
0.0,
0.0,
0.0,
0.0,
0.0,
0.0,
0.0,
0.0,
0.0,
0.0,
0.0,
-150.0,
0.0,
0.0,
],
),
atol=1e-5,
)
)
self.assertTrue(
np.allclose(
attack.vt_arr,
np.array(
[
0.0,
0.0,
0.0,
0.0,
0.0,
0.0,
0.0,
0.0,
0.0,
0.0,
0.0,
0.0,
0.0,
0.0,
0.0,
4000.0,
0.0,
0.0,
0.0,
0.0,
0.0,
0.0,
0.0,
0.0,
12250.0,
0.0,
0.0,
0.0,
0.0,
0.0,
0.0,
0.0,
1000.0,
0.0,
0.0,
0.0,
0.0,
0.0,
0.0,
0.0,
0.0,
0.0,
0.0,
0.0,
0.0,
2250.0,
0.0,
0.0,
],
),
atol=1e-5,
)
)
self.assertTrue(
np.allclose(
modifier,
np.array(
[
[
[-0.21563086, 0.54629284, 1.0879989],
[-0.17234534, 0.37302095, 1.5072422],
[-0.14709516, -0.08446954, -1.0199878],
[-0.46581882, 0.41346493, -1.6357177],
],
[
[0.97039294, -0.46038368, -0.5377948],
[-0.08485582, -1.4017423, -0.6447743],
[-0.6031785, -2.003339, -0.01103557],
[0.41714168, -1.94303, 0.6685426],
],
[
[-0.84051266, 0.79823476, 0.2532903],
[-0.76351106, 0.90984505, 1.331635],
[-1.1300149, -0.8444777, -2.2165612],
[1.0166003, 0.9233805, 0.98315567],
],
[
[-0.88205546, -0.3438152, -0.36559045],
[0.56274384, 1.5836877, -1.2370849],
[1.4234338, -0.5929535, -1.3011148],
[0.84360084, 0.90161383, 0.80880517],
],
],
),
atol=1e-5,
)
)
self.assertTrue(
(
attack.adam_epochs
== np.array(
[
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
2,
1,
1,
1,
1,
1,
1,
1,
1,
2,
1,
1,
1,
1,
1,
1,
1,
2,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
2,
1,
1,
],
)
).all(),
)
def test_get_new_prob(self):
probs = self.attack.get_new_prob(self.modifier, 2)
self.assertEqual(probs.shape, self.modifier.shape[1:])
# Integration Test
self.assertTrue(
np.allclose(
probs,
np.array(
[
[
[0.01471687, 0.02125866, 0.02285866],
[0.01471687, 0.02125866, 0.02285866],
[0.00914774, 0.03038241, 0.0248071],
[0.00914774, 0.03038241, 0.0248071],
],
[
[0.01471687, 0.02125866, 0.02285866],
[0.01471687, 0.02125866, 0.02285866],
[0.00914774, 0.03038241, 0.0248071],
[0.00914774, 0.03038241, 0.0248071],
],
[
[0.01337715, 0.02401802, 0.02019542],
[0.01337715, 0.02401802, 0.02019542],
[0.02158763, 0.01400388, 0.03364644],
[0.02158763, 0.01400388, 0.03364644],
],
[
[0.01337715, 0.02401802, 0.02019542],
[0.01337715, 0.02401802, 0.02019542],
[0.02158763, 0.01400388, 0.03364644],
[0.02158763, 0.01400388, 0.03364644],
],
]
),
atol=1e-5,
)
)
def test_resize_img(self):
# Reset Only True
attack = deepcopy(self.attack)
new_modifier = attack.resize_img(8, 8, 3, self.modifier, 2, reset_only=True)
self.assertEqual(new_modifier.shape, (1, 8, 8, 3))
self.assertEqual(attack.sample_prob.shape, np.prod(8 * 8 * 3))
# Reset Only False
attack = deepcopy(self.attack)
new_modifier = attack.resize_img(8, 8, 3, self.modifier, 2)
self.assertEqual(new_modifier.shape, (1, 8, 8, 3))
self.assertEqual(attack.sample_prob.shape, np.prod(8 * 8 * 3))
# Integration Test
self.assertTrue(
np.allclose(
new_modifier,
np.array(
[
[
[
[-0.21563086, 0.54629284, 1.0879989],
[-0.20480949, 0.50297487, 1.1928097],
[-0.18316671, 0.41633892, 1.4024314],
[-0.16603279, 0.25864834, 0.8754347],
[-0.15340771, 0.02990307, -0.38818032],
[-0.22677608, 0.04001407, -1.1739203],
[-0.3861379, 0.28898132, -1.4817853],
[-0.46581882, 0.41346493, -1.6357177],
],
[
[0.0808751, 0.2946237, 0.68155044],
[0.02316307, 0.2033003, 0.7534723],
[-0.09226094, 0.02065352, 0.89731616],
[-0.17775872, -0.19404912, 0.53499115],
[-0.23333023, -0.44080764, -0.3335028],
[-0.25710666, -0.4670549, -0.8407254],
[-0.24908802, -0.2727908, -0.98667693],
[-0.2450787, -0.17565879, -1.0596527],
],
[
[0.673887, -0.20871457, -0.1313464],
[0.47910815, -0.39604884, -0.12520233],
[0.0895506, -0.77071726, -0.11291426],
[-0.20121056, -1.099444, -0.14589605],
[-0.3931753, -1.3822291, -0.22414777],
[-0.31776786, -1.481193, -0.17433581],
[0.02501175, -1.396335, 0.00353971],
[0.19640155, -1.3539063, 0.09247744],
],
[
[0.51816654, -0.14572906, -0.34002355],
[0.32536998, -0.3152582, -0.29268563],
[-0.0602231, -0.6543164, -0.19800991],
[-0.3734866, -1.04629, -0.25373322],
[-0.61442065, -1.4911791, -0.45985574],
[-0.4094141, -1.5918247, -0.23538877],
[0.24153282, -1.3482264, 0.4196677],
[0.56700635, -1.2264273, 0.7471959],
],
[
[-0.38628626, 0.48358017, 0.05551901],
[-0.4380515, 0.4456721, 0.25102246],
[-0.54158205, 0.36985612, 0.6420292],
[-0.6945869, -0.03458703, 0.21147956],
[-0.89706624, -0.76765776, -1.0406268],
[-0.5320455, -0.7989503, -1.0238843],
[0.4004752, -0.12846482, 0.2617069],
[0.8667356, 0.20677787, 0.9045024],
],
[
[-0.8493984, 0.51272225, 0.09857011],
[-0.7450356, 0.6541181, 0.24629137],
[-0.5363101, 0.93690985, 0.54173374],
[-0.44687366, 0.6133301, 0.01979139],
[-0.4767264, -0.31662107, -1.319536],
[-0.12552696, -0.35671276, -1.2570076],
[0.60672456, 0.493055, 0.20737618],
[0.9728504, 0.9179388, 0.93956804],
],
[
[-0.87116975, -0.05830276, -0.21087027],
[-0.5955823, 0.3100797, -0.3068789],
[-0.04440734, 1.0468445, -0.49889636],
[0.369653, 0.89746165, -0.8287977],
[0.6465987, -0.1380692, -1.2965835],
[0.8101414, -0.26511204, -0.9347591],
[0.8602809, 0.51633304, 0.25667554],
[0.8853507, 0.9070555, 0.8523928],
],
[
[-0.88205546, -0.3438152, -0.36559045],
[-0.52085567, 0.13806051, -0.583464],
[0.20154402, 1.1018119, -1.0192113],
[0.7779163, 1.0395274, -1.2530923],
[1.2082613, -0.04879326, -1.2851074],
[1.2779756, -0.21931165, -0.7736348],
[0.98705906, 0.52797204, 0.28132522],
[0.84160084, 0.90161383, 0.80880517],
],
]
]
),
atol=1e-5,
)
)
self.assertTrue(
np.allclose(
attack.sample_prob,
np.array(
[
0.00367922,
0.00531467,
0.00571467,
0.00367922,
0.00531467,
0.00571467,
0.00367922,
0.00531467,
0.00571467,
0.00367922,
0.00531467,
0.00571467,
0.00228693,
0.0075956,
0.00620178,
0.00228693,
0.0075956,
0.00620178,
0.00228693,
0.0075956,
0.00620178,
0.00228693,
0.0075956,
0.00620178,
0.00367922,
0.00531467,
0.00571467,
0.00367922,
0.00531467,
0.00571467,
0.00367922,
0.00531467,
0.00571467,
0.00367922,
0.00531467,
0.00571467,
0.00228693,
0.0075956,
0.00620178,
0.00228693,
0.0075956,
0.00620178,
0.00228693,
0.0075956,
0.00620178,
0.00228693,
0.0075956,
0.00620178,
0.00367922,
0.00531467,
0.00571467,
0.00367922,
0.00531467,
0.00571467,
0.00367922,
0.00531467,
0.00571467,
0.00367922,
0.00531467,
0.00571467,
0.00228693,
0.0075956,
0.00620178,
0.00228693,
0.0075956,
0.00620178,
0.00228693,
0.0075956,
0.00620178,
0.00228693,
0.0075956,
0.00620178,
0.00367922,
0.00531467,
0.00571467,
0.00367922,
0.00531467,
0.00571467,
0.00367922,
0.00531467,
0.00571467,
0.00367922,
0.00531467,
0.00571467,
0.00228693,
0.0075956,
0.00620178,
0.00228693,
0.0075956,
0.00620178,
0.00228693,
0.0075956,
0.00620178,
0.00228693,
0.0075956,
0.00620178,
0.00334429,
0.00600451,
0.00504886,
0.00334429,
0.00600451,
0.00504886,
0.00334429,
0.00600451,
0.00504886,
0.00334429,
0.00600451,
0.00504886,
0.00539691,
0.00350097,
0.00841161,
0.00539691,
0.00350097,
0.00841161,
0.00539691,
0.00350097,
0.00841161,
0.00539691,
0.00350097,
0.00841161,
0.00334429,
0.00600451,
0.00504886,
0.00334429,
0.00600451,
0.00504886,
0.00334429,
0.00600451,
0.00504886,
0.00334429,
0.00600451,
0.00504886,
0.00539691,
0.00350097,
0.00841161,
0.00539691,
0.00350097,
0.00841161,
0.00539691,
0.00350097,
0.00841161,
0.00539691,
0.00350097,
0.00841161,
0.00334429,
0.00600451,
0.00504886,
0.00334429,
0.00600451,
0.00504886,
0.00334429,
0.00600451,
0.00504886,
0.00334429,
0.00600451,
0.00504886,
0.00539691,
0.00350097,
0.00841161,
0.00539691,
0.00350097,
0.00841161,
0.00539691,
0.00350097,
0.00841161,
0.00539691,
0.00350097,
0.00841161,
0.00334429,
0.00600451,
0.00504886,
0.00334429,
0.00600451,
0.00504886,
0.00334429,
0.00600451,
0.00504886,
0.00334429,
0.00600451,
0.00504886,
0.00539691,
0.00350097,
0.00841161,
0.00539691,
0.00350097,
0.00841161,
0.00539691,
0.00350097,
0.00841161,
0.00539691,
0.00350097,
0.00841161,
]
),
atol=1e-5,
)
)
def test_single_step(self):
# Random Without Importance and init size reduce
attack = ZooAttack(
model=self.model,
config=self.config,
input_image_shape=self.orig_img.shape[1:],
device="cpu:0",
)
attack.config["use_importance"] = False
attack.config["init_size"] = 2
modifier = deepcopy(self.modifier)
(
total_loss,
l2_loss,
confidence_loss,
model_output,
new_img,
) = attack.single_step(
modifier,
self.orig_img,
self.labels,
self.config["initial_const"],
max_pooling_ratio=2,
)
self.assertFalse(np.allclose(modifier, self.modifier, atol=1e-5))
self.assertEqual(new_img.shape, self.modifier.shape[1:])
# With Custom Indices
attack = deepcopy(self.attack)
modifier = deepcopy(self.modifier)
indices = [15, 24, 32, 45]
(
total_loss,
l2_loss,
confidence_loss,
model_output,
new_img,
) = attack.single_step(
modifier,
self.orig_img,
self.labels,
self.config["initial_const"],
var_indice=indices,
max_pooling_ratio=2,
)
self.assertFalse(np.allclose(modifier, self.modifier, atol=1e-5))
self.assertEqual(new_img.shape, self.modifier.shape[1:])
def test_attack(self):
attack = deepcopy(self.attack)
orig_img = deepcopy(self.orig_img[0].numpy())
orig_img /= 10 * np.max(orig_img)
labels = self.labels[0].numpy()
outer_best_adv, outer_best_const = attack.attack(
orig_img, labels, max_pooling_ratio=2
)
self.assertEqual(outer_best_adv.shape, self.modifier.shape[1:])
# Without x10
attack = deepcopy(self.attack)
orig_img = deepcopy(self.orig_img[0].numpy())
orig_img /= 100 * np.max(orig_img)
outer_best_adv, outer_best_const = attack.attack(
orig_img, labels, max_pooling_ratio=2
)
self.assertEqual(outer_best_adv.shape, self.modifier.shape[1:])
# With modifier init
attack = deepcopy(self.attack)
outer_best_adv, outer_best_const = attack.attack(
orig_img,
labels,
modifier_init=self.modifier[0],
max_pooling_ratio=2,
)
self.assertEqual(outer_best_adv.shape, self.modifier.shape[1:])
# With use resize and untargeted and max iterations 10k
attack = deepcopy(self.attack)
attack.config["use_resize"] = True
attack.config["resize_iter_1"] = 20
attack.config["resize_iter_2"] = 80
attack.config["abort_early"] = False
attack.config["targeted"] = False
orig_img = deepcopy(self.orig_img[0].numpy())
orig_img /= 10 * np.max(orig_img)
outer_best_adv, outer_best_const = attack.attack(
orig_img, labels, max_pooling_ratio=2
)
self.assertEqual(outer_best_adv.shape, self.modifier.shape[1:])
# Without tanh
attack = deepcopy(self.attack)
attack.config["use_tanh"] = False
outer_best_adv, outer_best_const = attack.attack(
orig_img, labels, max_pooling_ratio=2
)
self.assertEqual(outer_best_adv.shape, self.modifier.shape[1:])
|
1680267
|
from typing import Optional
import torch as th
def quantile_huber_loss(
current_quantiles: th.Tensor,
target_quantiles: th.Tensor,
cum_prob: Optional[th.Tensor] = None,
sum_over_quantiles: bool = True,
) -> th.Tensor:
"""
The quantile-regression loss, as described in the QR-DQN and TQC papers.
Partially taken from https://github.com/bayesgroup/tqc_pytorch.
:param current_quantiles: current estimate of quantiles, must be either
(batch_size, n_quantiles) or (batch_size, n_critics, n_quantiles)
:param target_quantiles: target of quantiles, must be either (batch_size, n_target_quantiles),
(batch_size, 1, n_target_quantiles), or (batch_size, n_critics, n_target_quantiles)
:param cum_prob: cumulative probabilities to calculate quantiles (also called midpoints in QR-DQN paper),
must be either (batch_size, n_quantiles), (batch_size, 1, n_quantiles), or (batch_size, n_critics, n_quantiles).
(if None, calculating unit quantiles)
:param sum_over_quantiles: if summing over the quantile dimension or not
:return: the loss
"""
if current_quantiles.ndim != target_quantiles.ndim:
raise ValueError(
f"Error: The dimension of curremt_quantile ({current_quantiles.ndim}) needs to match "
f"the dimension of target_quantiles ({target_quantiles.ndim})."
)
if current_quantiles.shape[0] != target_quantiles.shape[0]:
raise ValueError(
f"Error: The batch size of curremt_quantile ({current_quantiles.shape[0]}) needs to match "
f"the batch size of target_quantiles ({target_quantiles.shape[0]})."
)
if current_quantiles.ndim not in (2, 3):
raise ValueError(f"Error: The dimension of current_quantiles ({current_quantiles.ndim}) needs to be either 2 or 3.")
if cum_prob is None:
n_quantiles = current_quantiles.shape[-1]
# Cumulative probabilities to calculate quantiles.
cum_prob = (th.arange(n_quantiles, device=current_quantiles.device, dtype=th.float) + 0.5) / n_quantiles
if current_quantiles.ndim == 2:
# For QR-DQN, current_quantiles have a shape (batch_size, n_quantiles), and make cum_prob
# broadcastable to (batch_size, n_quantiles, n_target_quantiles)
cum_prob = cum_prob.view(1, -1, 1)
elif current_quantiles.ndim == 3:
# For TQC, current_quantiles have a shape (batch_size, n_critics, n_quantiles), and make cum_prob
# broadcastable to (batch_size, n_critics, n_quantiles, n_target_quantiles)
cum_prob = cum_prob.view(1, 1, -1, 1)
# QR-DQN
# target_quantiles: (batch_size, n_target_quantiles) -> (batch_size, 1, n_target_quantiles)
# current_quantiles: (batch_size, n_quantiles) -> (batch_size, n_quantiles, 1)
# pairwise_delta: (batch_size, n_target_quantiles, n_quantiles)
# TQC
# target_quantiles: (batch_size, 1, n_target_quantiles) -> (batch_size, 1, 1, n_target_quantiles)
# current_quantiles: (batch_size, n_critics, n_quantiles) -> (batch_size, n_critics, n_quantiles, 1)
# pairwise_delta: (batch_size, n_critics, n_quantiles, n_target_quantiles)
# Note: in both cases, the loss has the same shape as pairwise_delta
pairwise_delta = target_quantiles.unsqueeze(-2) - current_quantiles.unsqueeze(-1)
abs_pairwise_delta = th.abs(pairwise_delta)
huber_loss = th.where(abs_pairwise_delta > 1, abs_pairwise_delta - 0.5, pairwise_delta ** 2 * 0.5)
loss = th.abs(cum_prob - (pairwise_delta.detach() < 0).float()) * huber_loss
if sum_over_quantiles:
loss = loss.sum(dim=-2).mean()
else:
loss = loss.mean()
return loss
|
1680283
|
import numpy as np
import scipy.stats
import datetime
from spodernet.interfaces import IAtIterEndObservable, IAtEpochEndObservable, IAtEpochStartObservable
from spodernet.utils.util import Timer
from spodernet.utils.global_config import Config, Backends
from spodernet.utils.logger import Logger
log = Logger('hooks.py.txt')
class AbstractHook(IAtIterEndObservable, IAtEpochEndObservable):
def __init__(self, name, metric_name, print_every_x_batches):
self.epoch_errors = []
self.current_scores = []
self.name = name
self.iter_count = 0
self.print_every = print_every_x_batches
self.metric_name = metric_name
self.epoch = 1
# https://en.wikipedia.org/wiki/Algorithms_for_calculating_variance
self.n = 0
self.epoch_n = 0
self.mean = 0
self.M2 = 0
self.load_backend_specific_functions()
def load_backend_specific_functions(self):
if Config.backend == Backends.TORCH:
from torch.autograd import Variable
def convert_state(state):
if isinstance(state.targets, Variable):
state.targets = state.targets.data
if isinstance(state.argmax, Variable):
state.argmax = state.argmax.data
if isinstance(state.pred, Variable):
state.pred = state.pred.data
if isinstance(state.loss, Variable):
state.loss = state.loss.data
if isinstance(state.multi_labels, Variable):
state.multi_labels = state.multi_labels.data
return state
self.convert_state = convert_state
else:
self.convert_state = lambda x: x
def calculate_metric(self, state):
raise NotImplementedError('Classes that inherit from abstract hook need to implement the calcualte metric method.')
def at_end_of_iter_event(self, state):
state = self.convert_state(state)
metric = self.calculate_metric(state)
#print(metric)
self.n += 1
delta = metric - self.mean
self.mean += delta/self.n
delta2 = metric - self.mean
self.M2 += delta*delta2
self.current_scores.append(metric)
self.iter_count += 1
if self.iter_count % self.print_every == 0:
lower, upper, m, n = self.print_statistic()
self.n = 0
self.mean = 0
self.M2 = 0
return lower, upper, m, n
return 0, 0, self.mean, self.n
def at_end_of_epoch_event(self, state):
if self.n == 0: return 0, 0, 0, 0
self.epoch_errors.append(self.get_confidence_intervals())
lower, upper, m, n = self.print_statistic(True)
del self.current_scores[:]
self.n = 0
self.mean = 0
self.M2 = 0
self.epoch += 1
self.iter_count = 0
return lower, upper, m, n
def get_confidence_intervals(self, percentile=0.99, limit=1000):
z = scipy.stats.norm.ppf(percentile)
var = self.M2/ (self.n)
SE = np.sqrt(var/self.n)
lower = self.mean-(z*SE)
upper = self.mean+(z*SE)
return [self.n, lower, self.mean, upper]
def print_statistic(self, at_epoch_end=False):
n, lower, m, upper = self.get_confidence_intervals()
str_message = '{3} {4}: {2:.5}\t99% CI: ({0:.5}, {1:.5}), n={5}'.format(lower, upper, m, self.name, self.metric_name, self.n)
if at_epoch_end: log.info('\n')
if at_epoch_end: log.info('#'*40)
if at_epoch_end: log.info(' '*10 + 'COMPLETED EPOCH: {0}'.format(self.epoch) + ' '*30)
log.info(str_message)
if at_epoch_end: log.info('#'*40)
if at_epoch_end: log.info('\n')
return lower, upper, m, n
class AccuracyHook(AbstractHook):
def __init__(self, name='', print_every_x_batches=1000):
super(AccuracyHook, self).__init__(name, 'Accuracy', print_every_x_batches)
self.func = None
self.topk = 1
if Config.backend == Backends.TORCH:
import torch
self.func = lambda x: torch.sum(x)
def calculate_metric(self, state):
if Config.backend == Backends.TORCH:
correct = 0.0
if len(state.argmax.size()) == 1:
correct += self.func(state.targets==state.argmax)
else:
topk = state.argmax.size(1)
for i in range(topk):
correct += self.func(state.targets==state.argmax[:, i])
n = state.argmax.size()[0]
return correct.item()/np.float32(n)
elif Config.backend == Backends.TENSORFLOW:
n = state.argmax.shape[0]
return np.sum(state.targets==state.argmax)/np.float32(n)
elif Config.backend == Backends.TEST:
n = state.argmax.shape[0]
return np.sum(state.targets==state.argmax)/np.float32(n)
else:
raise Exception('Backend has unsupported value {0}'.format(Config.backend))
class TopKRankingLoss(AbstractHook):
def __init__(self, k, filtered=False, name='', print_every_x_batches=1000):
super(TopKRankingLoss, self).__init__(name, '{1}Hits@{0} loss'.format(k, ('' if not filtered else 'Filtered ')), print_every_x_batches)
self.func = None
self.argsort = None
self.sum_func = None
self.k = k
self.filtered = filtered
if Config.backend == Backends.TORCH:
import torch
self.argsort = lambda x, k: torch.topk(x, k)
self.sum_func = lambda x: torch.sum(x)
def calculate_metric(self, state):
if Config.backend == Backends.TORCH:
if self.filtered:
import torch
saved = torch.index_select(state.pred,1,state.targets)
state.pred[state.multi_labels.byte()] = -100000.0
state.pred.index_copy_(1, state.targets, saved)
max_values, argmax = self.argsort(state.pred, self.k)
in_topk = 0
for i in range(self.k):
in_topk += self.sum_func(argmax[:,i] == state.targets)
n = state.pred.size()[0]
return in_topk/np.float32(n)
else:
raise Exception('Backend has unsupported value {0}'.format(Config.backend))
class LossHook(AbstractHook):
def __init__(self, name='', print_every_x_batches=1000):
super(LossHook, self).__init__(name, 'Loss', print_every_x_batches)
def calculate_metric(self, state):
if Config.backend == Backends.TORCH:
state = self.convert_state(state)
return state.loss.item()
else:
return state.loss
class IntersectionHook(AbstractHook):
def __init__(self, name='', print_every_x_batches=1000):
super(IntersectionHook, self).__init__(name, 'Intersection', print_every_x_batches)
def calculate_metric(self, state):
state = self.convert_state(state)
preds = state.pred
targets = state.targets
if Config.cuda:
preds = preds.cpu()
targets = targets.cpu()
preds = preds.numpy()
targets = targets.numpy()
n = targets.size
k = 0
for row in range(Config.batch_size):
k += np.intersect1d(preds[row], targets[row]).size
return k/float(n)
class ETAHook(AbstractHook, IAtEpochStartObservable):
def __init__(self, name='', print_every_x_batches=1000):
super(ETAHook, self).__init__(name, 'ETA', print_every_x_batches)
self.t = Timer(silent=True)
self.cumulative_t = 0.0
self.skipped_first = False
def get_time_string(self, seconds):
m, s = divmod(seconds, 60)
h, m = divmod(m, 60)
if h < 0: h = 0
if m < 0: m = 0
if s < 0: s = 0
return "%d:%02d:%02d" % (h, m, s)
def calculate_metric(self, state):
n = state.num_batches
i = state.current_idx
cumulative_t = self.t.tick('ETA')
total_time_estimate = (cumulative_t/i)*n
self.t.tick('ETA')
self.cumulative_t = cumulative_t
return total_time_estimate
def print_statistic(self):
if not self.skipped_first:
# the first estimation is very unreliable for time measures
self.skipped_first = True
return 0, 0, 0, 0
n, lower, m, upper = self.get_confidence_intervals()
lower -= self.cumulative_t
m -= self.cumulative_t
upper -= self.cumulative_t
lower, m, upper = self.get_time_string(lower), self.get_time_string(m), self.get_time_string(upper)
log.info('{3} {4}: {2}\t99% CI: ({0}, {1}), n={5}'.format(lower, upper, m, self.name, self.metric_name, n))
return lower, upper, m, n
def at_start_of_epoch_event(self, batcher_state):
self.t.tick('ETA')
t = self.t.tick('Epoch')
def at_end_of_epoch_event(self, state):
self.t.tock('ETA')
epoch_time = self.t.tock('Epoch')
self.epoch_errors.append([epoch_time])
log.info('Total epoch time: {0}'.format(self.get_time_string(epoch_time)))
del self.current_scores[:]
self.n = 0
self.mean = 0
self.M2 = 0
self.skipped_first = False
self.epoch += 1
return epoch_time
|
1680297
|
import os
import sys
import time
import numpy as np
import Pyro4
import select
from slam_pkg.utils.map_builder import MapBuilder as mb
from slam_pkg.utils import depth_util as du
from skimage.morphology import disk, binary_dilation
from rich import print
Pyro4.config.SERIALIZER = "pickle"
Pyro4.config.SERIALIZERS_ACCEPTED.add("pickle")
Pyro4.config.PICKLE_PROTOCOL_VERSION = 4
@Pyro4.expose
class SLAM(object):
def __init__(
self,
robot,
map_size=4000,
resolution=5,
robot_rad=30,
agent_min_z=5,
agent_max_z=70,
obstacle_threshold=1,
):
self.robot = robot
self.robot_rad = robot_rad
self.map_resolution = resolution
self.map_builder = mb(
map_size_cm=map_size,
resolution=resolution,
agent_min_z=agent_min_z,
agent_max_z=agent_max_z,
obs_thr=obstacle_threshold,
)
self.map_size = map_size
# if the map is a previous map loaded from disk, and
# if the robot looks around and registers itself at a
# non-origin location in the map just as it is coming up,
# then the robot's reported origin (from get_base_state) is
# not the map's origin. In such cases, `self.init_state`
# is useful, as it is used to handle all co-ordinate transforms
# correctly.
# Currently, self.init_state is kinda useless and not utilized
# in any meaningful way
self.init_state = (0.0, 0.0, 0.0)
self.prev_bot_state = (0.0, 0.0, 0.0)
self.update_map()
assert self.traversable is not None
def get_traversable_map(self):
return self.traversable
def real2map(self, real):
return self.map_builder.real2map(real)
def map2real(self, map_loc):
return self.map_builder.map2real(map_loc)
def robot2map(self, robot_loc):
# TODO: re-enable this code when init_state can be non-zero
# robot_location = du.get_relative_state(
# robot_loc,
# self.init_state)
return self.real2map(robot_loc)
def map2robot(self, map_loc):
return self.map2real(map_loc)
# TODO: re-enable and test this code when init_state can be non-zero
# real_loc = self.map2real(map_loc)
# loc = du.get_relative_state(real_loc, (0.0, 0.0, -self.init_state[2]))
# # 2) add the offset
# loc = list(loc)
# loc[0] += self.init_state[0]
# loc[1] += self.init_state[1]
# return tuple(loc)
def add_obstacle(self, location, in_map=False):
"""
add an obstacle at the given location.
if in_map=False, then location is given in real co-ordinates
if in_map=True, then location is given in map co-ordinates
"""
if not in_map:
location = self.real2map(location)
self.map_builder.add_obstacle(location)
def update_map(self):
pcd = self.robot.get_current_pcd()[0]
self.map_builder.update_map(pcd)
# explore the map by robot shape
obstacle = self.map_builder.map[:, :, 1] >= 1.0
selem = disk(self.robot_rad / self.map_builder.resolution)
traversable = binary_dilation(obstacle, selem) != True
self.traversable = traversable
def get_map_resolution(self):
return self.map_resolution
def get_map(self):
"""returns the location of obstacles created by slam only for the obstacles,"""
# get the index correspnding to obstacles
indices = np.where(self.map_builder.map[:, :, 1] >= 1.0)
# convert them into robot frame
real_world_locations = [
self.map2real([indice[0], indice[1]]).tolist()
for indice in zip(indices[0], indices[1])
]
return real_world_locations
def reset_map(self, z_bins=None, obs_thr=None):
self.map_builder.reset_map(self.map_size, z_bins=z_bins, obs_thr=obs_thr)
robot_ip = os.getenv("LOCOBOT_IP")
ip = os.getenv("LOCAL_IP")
robot_name = "remotelocobot"
if len(sys.argv) > 1:
robot_name = sys.argv[1]
with Pyro4.Daemon(ip) as daemon:
robot = Pyro4.Proxy("PYRONAME:" + robot_name + "@" + robot_ip)
if robot_name == "hello_realsense":
robot_height = 141 # cm
min_z = 20 # because of the huge spatial variance in realsense readings
max_z = robot_height + 5 # cm
obj = SLAM(
robot,
obstacle_threshold=10,
agent_min_z=min_z,
agent_max_z=max_z,
)
else:
obj = SLAM(robot)
obj_uri = daemon.register(obj)
with Pyro4.locateNS(robot_ip) as ns:
ns.register("slam", obj_uri)
print("SLAM Server is started...")
def refresh():
obj.update_map()
# print("In refresh: ", time.asctime())
return True
daemon.requestLoop(refresh)
# visit this later
# try:
# while True:
# print(time.asctime(), "Waiting for requests...")
# sockets = daemon.sockets
# ready_socks = select.select(sockets, [], [], 0)
# events = []
# for s in ready_socks:
# events.append(s)
# daemon.events(events)
# except KeyboardInterrupt:
# pass
|
1680304
|
from keras.layers import Input, LSTM, Dense, Masking, merge, Dropout
from keras.models import Model, load_model
from keras.optimizers import adam
from keras.utils import to_categorical
import numpy as np
from numpy import genfromtxt, savetxt
from matplotlib import pyplot as plt
data_dir = './split2/scene_activity_data_test_none'
model_path = './scenelstm/scenelstm-split1.h5'
batch_size = 128
trainX1 = (genfromtxt(data_dir + '/' + 'trainX1.csv', delimiter=','))
trainX2 = np.reshape(genfromtxt(data_dir + '/' + 'trainX2.csv', delimiter=','), newshape=(-1, 10, 2048))
trainY = to_categorical(genfromtxt(data_dir + '/' + 'trainY.csv', delimiter=',') - 1)
testX1 = (genfromtxt(data_dir + '/' + 'testX1.csv', delimiter=','))
testX2 = np.reshape(genfromtxt(data_dir + '/' + 'testX2.csv', delimiter=','), newshape=(-1, 10, 2048))
testY = to_categorical(genfromtxt(data_dir + '/' + 'testY.csv', delimiter=',') - 1)
print(trainX1.shape, trainX2.shape, trainY.shape, testX1.shape, testX2.shape, testY.shape)
# freq_layer = Input(shape=(4,))
# context_layer = Input(shape=(10, 2048))
# masked = Masking()(context_layer)
# lstm1 = LSTM(256, activation='sigmoid', recurrent_activation='tanh')(masked)
# drop1 = Dropout(rate=0.95)(lstm1)
# fc_context = Dense(16, activation='tanh')(drop1)
# fc_freq = Dense(16, activation='tanh')(freq_layer)
# merged = merge(inputs=[fc_context, fc_freq], mode='concat', concat_axis=1)
# fc2 = Dense(5, activation='softmax')(merged)
# scene_net = Model(inputs=[freq_layer, context_layer], outputs=fc2)
# print(scene_net.summary())
#
# optm = adam(lr=0.001)
# scene_net.compile(optimizer=optm, loss='categorical_crossentropy', metrics=['accuracy'])
scene_net = load_model(model_path)
print(testY.shape, trainY.shape)
scores = scene_net.evaluate(x=[testX1, testX2], y=testY, batch_size=batch_size)
y_fit = scene_net.predict(x=[testX1, testX2])
savetxt(data_dir + '/' + 'scene_res_none.txt', np.hstack((y_fit, testY)))
print(scores)
|
1680313
|
from django.utils.safestring import mark_safe
from fluent_pages.extensions import PageTypePlugin, page_type_pool
from fluent_pages.pagetypes.flatpage.models import FlatPage
@page_type_pool.register
class FlatPagePlugin(PageTypePlugin):
model = FlatPage
sort_priority = 11
def get_render_template(self, request, flatpage, **kwargs):
return flatpage.template_name
def get_context(self, request, page, **kwargs):
context = super().get_context(request, page, **kwargs)
# Just like django.contrib.flatpages, mark content as safe:
page = context["page"]
page.content = mark_safe(page.content)
return context
|
1680374
|
import read_bvh
import numpy as np
from os import listdir
import os
def generate_traindata_from_bvh(src_bvh_folder, tar_traindata_folder):
print ("Generating training data for "+ src_bvh_folder)
if (os.path.exists(tar_traindata_folder)==False):
os.makedirs(tar_traindata_folder)
bvh_dances_names=listdir(src_bvh_folder)
for bvh_dance_name in bvh_dances_names:
name_len=len(bvh_dance_name)
if(name_len>4):
if(bvh_dance_name[name_len-4: name_len]==".bvh"):
print ("Processing "+bvh_dance_name)
dance=read_bvh.get_train_data(src_bvh_folder+bvh_dance_name)
np.save(tar_traindata_folder+bvh_dance_name+".npy", dance)
def generate_bvh_from_traindata(src_train_folder, tar_bvh_folder):
print ("Generating bvh data for "+ src_train_folder)
if (os.path.exists(tar_bvh_folder)==False):
os.makedirs(tar_bvh_folder)
dances_names=listdir(src_train_folder)
for dance_name in dances_names:
name_len=len(dance_name)
if(name_len>4):
if(dance_name[name_len-4: name_len]==".npy"):
print ("Processing"+dance_name)
dance=np.load(src_train_folder+dance_name)
dance2=[]
for i in range(dance.shape[0]/8):
dance2=dance2+[dance[i*8]]
print (len(dance2))
read_bvh.write_traindata_to_bvh(tar_bvh_folder+dance_name+".bvh",np.array(dance2))
generate_traindata_from_bvh("../train_data_bvh/indian/","../train_data_xyz/indian/")
#generate_traindata_from_bvh("../train_data_bvh/salsa/","../train_data_xyz/salsa/")
#generate_traindata_from_bvh("../train_data_bvh/martial/","../train_data_xyz/martial/")
|
1680383
|
import argparse
import os
import pandas as pd
import numpy as np
from tqdm import tqdm
from sklearn.model_selection import train_test_split
tqdm.pandas()
parser = argparse.ArgumentParser()
parse.add_argument("--mimic_dir", help="The directory contaning all the required MIMIC files (ADMISSIONS, PATIENTS, DIAGNOSES_ICD, PROCEDURES_ICD, NOTEEVENTS).")
parse.add_argument("--save_dir", help="The directory where you want to save the processed files.")
args = parser.parse_args()
# ## Load data and clean admission
raw_adm = pd.read_csv(args.mimic_dir + "ADMISSIONS.csv.gz")
raw_patients = pd.read_csv(args.mimic_dir + 'PATIENTS.csv.gz')
dicd = pd.read_csv(args.mimic_dir + 'DIAGNOSES_ICD.csv.gz')
picd = pd.read_csv(args.mimic_dir + 'PROCEDURES_ICD.csv.gz')
raw_notes = pd.read_csv(args.mimic_dir + "NOTEEVENTS.csv")
# First only keep the admission IDs that are in the notes as well
adm = raw_adm.copy()
adm_in_notes = notes.HADM_ID.unique()
adm = adm[adm.HADM_ID.isin(adm_in_notes)]
# ## Process notes dataframe
#
# - Add information about death and discharge time
# - Ensures to only keep notes that were written at least 24h before discharge
# - Sample negative notes by randomly selecting at most 4 notes per patient.
# - Recombine everything to get a balanced dataset
notes = raw_notes.copy()
categories_keep = ['Nursing', 'Physician ', 'Nursing/other']
notes = notes[notes.CATEGORY.isin(categories_keep)]
notes = notes.merge(
adm[['HADM_ID', 'DISCHTIME', 'HOSPITAL_EXPIRE_FLAG']],
on='HADM_ID', how='left'
)
# Time manipulation
notes.DISCHTIME = pd.to_datetime(notes.DISCHTIME)
notes.CHARTTIME = pd.to_datetime(notes.CHARTTIME)
notes.CHARTDATE = pd.to_datetime(notes.CHARTDATE) + pd.DateOffset(hours=23)
notes.CHARTTIME = notes.CHARTTIME.fillna(notes.CHARTDATE)
notes = notes[notes.CHARTTIME < notes.DISCHTIME - pd.DateOffset(hours=24)]
keep_cols = ['HADM_ID', 'SUBJECT_ID', 'TEXT', 'HOSPITAL_EXPIRE_FLAG']
pos_notes = notes.loc[notes.HOSPITAL_EXPIRE_FLAG == 1, keep_cols]
neg_notes = (
notes
.loc[:, keep_cols]
.query("HOSPITAL_EXPIRE_FLAG == 0")
.groupby("HADM_ID")
.progress_apply(lambda df: df.sample(n=4) if df.shape[0] >= 4 else df)
.reset_index(drop=True)
)
sampled_notes = pd.concat([pos_notes, neg_notes]).drop_duplicates()
sampled_notes.HOSPITAL_EXPIRE_FLAG.value_counts()
# ## Process text content and split data
def isolate(text, chars):
for c in chars:
text = text.replace(c, f" {c} ")
return text
def replace(text, chars, new=""):
for c in chars:
text = text.replace(c, new)
return text
def clean_text(text):
text = replace(text, "[**")
text = replace(text, "**]")
text = isolate(text, "~!@#$%^&*()_+-={}:\";',./<>?\\|`'")
text = text.lower()
return text
sampled_notes.TEXT = sampled_notes.TEXT.progress_apply(clean_text)
subjects = sampled_notes[['SUBJECT_ID', "HOSPITAL_EXPIRE_FLAG"]].drop_duplicates()
train_subj, rest_subj = train_test_split(
subjects,
test_size=0.25,
random_state=0,
stratify=subjects.HOSPITAL_EXPIRE_FLAG
)
valid_subj, test_subj = train_test_split(
rest_subj.SUBJECT_ID.values,
test_size=0.6,
random_state=1,
stratify=rest_subj.HOSPITAL_EXPIRE_FLAG
)
train_subj = train_subj.SUBJECT_ID.values
train_notes = sampled_notes[sampled_notes.SUBJECT_ID.isin(train_subj)].reset_index(drop=True)
valid_notes = sampled_notes[sampled_notes.SUBJECT_ID.isin(valid_subj)].reset_index(drop=True)
test_notes = sampled_notes[sampled_notes.SUBJECT_ID.isin(test_subj)].reset_index(drop=True)
# ## Save
os.makedirs(args.save_dir, exist_ok=True)
train_notes.to_csv(os.path.join(args.save_dir, "train.csv"), index=False)
valid_notes.to_csv(os.path.join(args.save_dir, "valid.csv"), index=False)
test_notes.to_csv(os.path.join(args.save_dir, "test.csv"), index=False)
|
1680394
|
from mltoolkit.mldp.steps.transformers import BaseTransformer
import numpy as np
class InvalidTransformer(BaseTransformer):
def _transform(self, data_chunk):
return np.random.random((10, 5))
|
1680428
|
from typing import Any, Dict, List, Optional, Union
import pyspark
import pyspark.sql.functions as F
from pyspark.ml.linalg import Vectors, VectorUDT
from pyspark.sql.functions import udf
from pyspark.sql.types import FloatType
class SLearnerEstimator:
"""Estimates treatment effect by training a single model for E[Y | T, X], applying the model with T=1 and T=0 and using the difference in these estimates as the estimated treatment effect.
The name S-learner originates from Künzel et al. (2019) (https://arxiv.org/pdf/1706.03461.pdf).
"""
def __init__(
self,
base_model_class: Any,
base_model_params: Dict,
predictors_colname: str = "features",
treatment_colname: str = "treatment",
target_colname: str = "outcome",
treatment_value: int = 1,
control_value: int = 0,
output_colname: str = "score",
):
"""Initializes the S-learner.
Args:
base_model_class (pyspark.ml): the MLlib model class to instantiate the S-learner with
base_model_params (dict): parameters and their values for the model
predictors_colname (str, optional): the column names that contain the predictor variables
treatment_colname (str, optional): the column name that contains the treatment indicators
target_colname (str, optional): the column name that contains the target
treatment_value (str or int, optional): the value in column <treatment_colname> that refers to the treatment group
control_value (str or int, optional): the value in column <treatment_colname> that refers to the control group
output_colname (str, optional): the column name for the estimator output
"""
base_model_params["featuresCol"] = "features_train"
base_model_params["labelCol"] = target_colname
self.predictors_colname = predictors_colname
self.model = base_model_class(**base_model_params)
self.treatment_colname = treatment_colname
self.target_colname = target_colname
self.control_value = control_value
self.treatment_value = treatment_value
self.output_colname = output_colname
def fit(self, df_train: pyspark.sql.DataFrame, df_val: Optional[Any] = None) -> None:
"""Trains the S-learner.
Args:
df_train (pyspark.sql.DataFrame): a dataframe containing the treatment indicators, the observed outcomes, and predictors
df_val (pyspark.sql.DataFrame): a dataframe containing the treatment indicators, the observed outcomes, and predictors
"""
add_treatment_udf = udf(lambda v, e: Vectors.dense(list(v) + [e]), VectorUDT())
df_train = df_train.withColumn(
"features_train", add_treatment_udf(self.predictors_colname, self.treatment_colname)
)
self.model = self.model.fit(df_train)
def predict(self, df: pyspark.sql.DataFrame) -> pyspark.sql.DataFrame:
"""Applies the S-learner and returns treatment effect predictions.
Args:
df (pyspark.sql.DataFrame): a dataframe containing predictors
Returns:
df (pyspark.sql.DataFrame): a dataframe containing predictors containing treatment effect predictions
"""
df = df.withColumn("original_treatment", F.col(self.treatment_colname))
df_cols = df.columns
df = df.withColumn(self.treatment_colname, F.lit(self.control_value))
add_treatment_udf = udf(lambda v, e: Vectors.dense(list(v) + [e]), VectorUDT())
df = df.withColumn("features_train", add_treatment_udf(self.predictors_colname, self.treatment_colname))
df = self.model.transform(df)
if "probability" not in df.columns:
split_udf = udf(lambda value: value, FloatType())
pred_col = "prediction"
else:
split_udf = udf(lambda value: value[1].item(), FloatType())
pred_col = "probability"
df = df.withColumn("pred_control", split_udf(pred_col)).select([*df_cols, "pred_control"])
df = df.withColumn(self.treatment_colname, F.lit(self.treatment_value))
df = df.withColumn("features_train", add_treatment_udf(self.predictors_colname, self.treatment_colname))
df = (
self.model.transform(df)
.withColumn("pred_treatment", split_udf(pred_col))
.select([*df_cols, "pred_control", "pred_treatment"])
)
df = df.withColumn(self.output_colname, F.col("pred_treatment") - F.col("pred_control"))
df = df.withColumn(self.treatment_colname, F.col("original_treatment"))
df = df.select([*df_cols, self.output_colname]).drop("original_treatment")
return df
class TLearnerEstimator:
"""Estimates treatment effect as the difference in estimates from two separate models: E[Y | T=1, X] - E[Y | T=0, X].
The two-model approach is widely used for treatment effect estimation. The name T-learner originates from Künzel et al. (2019) (https://arxiv.org/pdf/1706.03461.pdf).
"""
def __init__(
self,
base_model_class: Any,
base_model_params: Dict,
predictors_colname: str = "features",
treatment_colname: str = "treatment",
target_colname: str = "outcome",
treatment_value: int = 1,
control_value: int = 0,
output_colname: str = "score",
):
"""Initializes the T-learner.
Args:
base_model_class (pyspark.ml): the model class to instantiate the T-learner with
base_model_params (dict): parameters and their values for the models
predictors_colname (str, optional): the column names that contain the predictor variables
treatment_colname (str, optional): the column name that contains the treatment indicators
target_colname (str, optional): the column name that contains the target
treatment_value (str or int, optional): the value in column <treatment_colname> that refers to the treatment group
control_value (str or int, optional): the value in column <treatment_colname> that refers to the control group
output_colname (str, optional): the column name for the estimator output
"""
base_model_params["featuresCol"] = predictors_colname
base_model_params["labelCol"] = target_colname
self.model0 = base_model_class(**base_model_params)
self.model1 = base_model_class(**base_model_params)
self.treatment_colname = treatment_colname
self.target_colname = target_colname
self.control_value = control_value
self.treatment_value = treatment_value
self.output_colname = output_colname
def fit(self, df_train: pyspark.sql.DataFrame, df_val: Optional[Any] = None) -> None:
"""Trains the T-learner.
Args:
df_train (pyspark.sql.DataFrame): a dataframe containing the treatment indicators, the observed outcomes, and predictors
df_val (pyspark.sql.DataFrame): a dataframe containing the treatment indicators, the observed outcomes, and predictors
"""
self.model1 = self.model1.fit(df_train.where(F.col(self.treatment_colname) == self.treatment_value))
self.model0 = self.model0.fit(df_train.where(F.col(self.treatment_colname) == self.control_value))
def predict(self, df: pyspark.sql.DataFrame) -> pyspark.sql.DataFrame:
"""Applies the T-learner and returns treatment effect predictions.
Args:
df (pyspark.sql.DataFrame): a dataframe containing predictors
Returns:
df (pyspark.sql.DataFrame): a dataframe containing treatment effect predictions
"""
df_cols = df.columns
df = self.model0.transform(df)
if "probability" not in df.columns:
split_udf = udf(lambda value: value, FloatType())
pred_col = "prediction"
else:
split_udf = udf(lambda value: value[1].item(), FloatType())
pred_col = "probability"
df = df.withColumn("pred_control", split_udf(pred_col)).select([*df_cols, "pred_control"])
df = (
self.model1.transform(df)
.withColumn("pred_treatment", split_udf(pred_col))
.select([*df_cols, "pred_control", "pred_treatment"])
)
df = df.withColumn(self.output_colname, F.col("pred_treatment") - F.col("pred_control"))
df = df.select([*df_cols, self.output_colname])
return df
class XLearnerEstimator:
"""Estimates treatment effect in three stages:
1. Train a T-learner to get scores Y_hat_1 and Y_hat_0.
2. Train regression models to predict the residuals: tau1 = E[Y(1) - Y_hat_1) | X] and tau0 = E[Y_hat_0 - Y(0) | X]
3. Estimate the treatment effect as a weighted average: tau(X) = p(X) * tau0(X) + (1 - p(X)) * tau1(X). Our implementation sets p(X) = 0.5 for all X.
X-learner was proposed in Künzel et al. (2019) (https://arxiv.org/pdf/1706.03461.pdf).
"""
def __init__(
self,
base_model_class_1: Any,
base_model_params_1: Dict,
base_model_class_2: Any,
base_model_params_2: Dict,
predictors_colname_2: str = "features",
predictors_colname_1: str = "features",
treatment_colname: str = "treatment",
target_colname: str = "outcome",
treatment_value: int = 1,
control_value: int = 0,
output_colname: str = "score",
):
"""Initializes the X-learner.
Args:
base_model_class_1 (pyspark.ml): the model class to instantiate the first stage learners
base_model_params_1 (dict): parameters and their values for the first stage models
predictors_colname_1 (list of str): the column names that contain the predictor variables for the first stage models
base_model_class_2 (): the model class to instantiate the second stage learners
base_model_params_2 (dict): parameters and their values for the second stage models. The models must be regressors.
predictors_colname_2 (list of str): the column names that contain the predictor variables for the second stage models
treatment_colname (str, optional): the column name that contains the treatment indicators
target_colname (str, optional): the column name that contains the target
treatment_value (str or int, optional): the value in column <treatment_colname> that refers to the treatment group
control_value (str or int, optional): the value in column <treatment_colname> that refers to the control group
output_colname (str, optional): the column name for the estimator output
"""
self.first_learner = TLearnerEstimator(
base_model_class_1,
base_model_params_1,
predictors_colname_1,
treatment_colname,
target_colname,
treatment_value,
control_value,
)
self.second_learner = TLearnerEstimator(
base_model_class_2,
base_model_params_2,
predictors_colname_2,
treatment_colname,
"D",
treatment_value,
control_value,
)
self.treatment_colname = treatment_colname
self.target_colname = target_colname
self.control_value = control_value
self.treatment_value = treatment_value
self.output_colname = output_colname
def fit(self, df_train: pyspark.sql.DataFrame, df_val: Optional[Any] = None) -> None:
"""Trains the X-learner.
Args:
df_train (pyspark.sql.DataFrame): a dataframe containing the treatment indicators, the observed outcomes, and predictors
df_val (pyspark.sql.DataFrame): a dataframe containing the treatment indicators, the observed outcomes, and predictors
"""
self.first_learner.fit(df_train)
df_train = self._get_second_learner_targets(df_train)
self.second_learner.fit(df_train)
def predict(self, df: pyspark.sql.DataFrame) -> pyspark.sql.DataFrame:
"""Applies the X-learner and returns treatment effect predictions.
Args:
df (pyspark.sql.DataFrame): a dataframe containing predictors
Returns:
df (pyspark.sql.DataFrame): a dataframe containing treatment effect predictions
"""
df = self._get_second_learner_targets(df)
df_cols = df.columns
df = self.second_learner.model0.transform(df)
if "probability" not in df.columns:
split_udf = udf(lambda value: value, FloatType())
pred_col = "prediction"
else:
split_udf = udf(lambda value: value[1].item(), FloatType())
pred_col = "probability"
df = df.withColumn("pred_control", split_udf(pred_col)).select([*df_cols, "pred_control"])
df = (
self.second_learner.model1.transform(df)
.withColumn("pred_treatment", split_udf(pred_col))
.select([*df_cols, "pred_control", "pred_treatment"])
)
df = df.withColumn(self.output_colname, 0.5 * (F.col("pred_treatment") + F.col("pred_control")))
df = df.select([*df_cols, self.output_colname]).drop("D")
return df
def _get_second_learner_targets(self, df: pyspark.sql.DataFrame) -> pyspark.sql.DataFrame:
"""Applies the first stage models and returns the targets for the second stage model.
Args:
df (pyspark.sql.DataFrame): a dataframe containing the treatment indicators, the observed outcomes, and predictors
Returns:
df (pyspark.sql.DataFrame): a dataframe containing the second stage targets for the X-learner
"""
df_cols = df.columns
df = self.first_learner.model0.transform(df)
if "probability" not in df.columns:
split_udf = udf(lambda value: value, FloatType())
pred_col = "prediction"
else:
split_udf = udf(lambda value: value[1].item(), FloatType())
pred_col = "probability"
df = df.withColumn("preds0", split_udf(pred_col)).select([*df_cols, "preds0"])
df = (
self.first_learner.model1.transform(df)
.withColumn("preds1", split_udf(pred_col))
.select([*df_cols, "preds0", "preds1"])
)
df = df.withColumn(
"D",
F.when(
F.col(self.treatment_colname) == self.treatment_value, F.col(self.target_colname) - F.col("preds0")
).otherwise(F.col("preds1") - F.col(self.target_colname)),
)
return df.select([*df_cols, "D"])
class CVTEstimator:
"""Estimates treatment effect by transforming the target variable into a new target variable Z, such that the treatment effect tau(X) = 2 * E[Z | X] - 1.
This transformation results in a classification problem and is, thus, slightly different from the TransformedOutcomeEstimator, which results in a regression problem.
Can only be used with 50-50 treatment vs. control RCT data.
The Class Variable Transformation technique was proposed in Jaskowski and Jaroszewicz (2012) (http://people.cs.pitt.edu/~milos/icml_clinicaldata_2012/Papers/Oral_Jaroszewitz_ICML_Clinical_2012.pdf).
"""
def __init__(
self,
base_model_class: Any,
base_model_params: Dict,
predictors_colname: str = "features",
treatment_colname: str = "treatment",
target_colname: str = "outcome",
output_colname: str = "score",
):
"""Initializes the CVTEstimator.
Args:
base_model_class (pyspark.ml): the model class to instantiate the CVTEstimator with
base_model_params (dict): parameters and their values for the model
predictors_colname (str, optional): the column names that contain the predictor variables
treatment_colname (str, optional): the column name that contains the treatment indicators
target_colname (str, optional): the column name that contains the target
output_colname (str, optional): the column name for the estimator output
"""
base_model_params["featuresCol"] = predictors_colname
base_model_params["labelCol"] = "cvt_label"
self.model = base_model_class(**base_model_params)
self.predictors_colname = predictors_colname
self.treatment_colname = treatment_colname
self.target_colname = target_colname
self.output_colname = output_colname
def fit(self, df_train: pyspark.sql.DataFrame, df_val: Optional[Any] = None) -> None:
"""Trains the CVT model by transforming the target variable and fitting a classifier on the transformed targets.
Args:
df_train (pyspark.sql.DataFrame): a dataframe containing the treatment indicators, the observed outcomes, and predictors
df_val (pyspark.sql.DataFrame): a dataframe containing the treatment indicators, the observed outcomes, and predictors
"""
df_train = df_train.withColumn(
"cvt_label", F.when(F.col(self.treatment_colname) == F.col(self.target_colname), 1).otherwise(0)
)
self.model = self.model.fit(df_train)
def predict(self, df: pyspark.sql.DataFrame) -> pyspark.sql.DataFrame:
"""Applies the CVT model and returns treatment effect predictions.
Args:
df (pyspark.sql.DataFrame): a dataframe containing predictors
Returns:
df (pyspark.sql.DataFrame): a dataframe containing treatment effect predictions
"""
df_cols = df.columns
df = df.withColumn(
"cvt_label", F.when(F.col(self.treatment_colname) == F.col(self.target_colname), 1).otherwise(0)
)
df = self.model.transform(df)
split_udf = udf(lambda value: value[1].item(), FloatType())
df = df.withColumn("prob", split_udf("probability"))
df = df.withColumn(self.output_colname, 2 * F.col("prob") - 1)
df = df.select([*df_cols, self.output_colname])
return df
class TransformedOutcomeEstimator:
"""Estimates treatment effect by transforming the outcome, such that the expectation of the transformed outcome corresponds to the treatment effect.
This transformation results in a regression problem and is, thus, slightly different from the CVTEstimator, which results in a classification problem.
The Transformed Outcome technique was proposed in Athey and Imbens (2015) (https://pdfs.semanticscholar.org/86ce/004214845a1683d59b64c4363a067d342cac.pdf).
"""
def __init__(
self,
base_model_class: Any,
base_model_params: Dict,
predictors_colname: str = "features",
propensity_model_class: Any = None,
propensity_model_params: Dict = None,
treatment_colname: str = "treatment",
target_colname: str = "outcome",
treatment_value: int = 1,
control_value: int = 0,
output_colname: str = "score",
):
"""Initializes the TransformedOutcomeEstimator.
Args:
base_model_class (pyspark.ml): the model class to instantiate the TransformedOutcomeEstimator with
base_model_params (dict): parameters and their values for the model. The model must be a regressor.
predictors_colname (str, optional): the column names that contain the predictor variables
propensity_model_class (, optional): the model class to instantiate the propensity model. If None, propensity will be estimated as the overall proportion of treated users in the training data.
propensity_model_params (dict, optional): parameters and their values for the propensity model. Not used if <propensity_model_class> is None.
treatment_colname (str, optional): the column name that contains the treatment indicators
target_colname (str, optional): the column name that contains the target
treatment_value (str or int, optional): the value in column <treatment_colname> that refers to the treatment group
control_value (str or int, optional): the value in column <treatment_colname> that refers to the control group
output_colname (str, optional): the column name for the estimator output
"""
base_model_params["featuresCol"] = predictors_colname
base_model_params["labelCol"] = "D"
self.model = base_model_class(**base_model_params)
self.propensity_estimator = PropensityEstimator(
propensity_model_class, propensity_model_params, predictors_colname, treatment_colname, treatment_value
)
self.predictors_colname = predictors_colname
self.treatment_colname = treatment_colname
self.target_colname = target_colname
self.control_value = control_value
self.treatment_value = treatment_value
self.output_colname = output_colname
def fit(self, df_train: pyspark.sql.DataFrame, df_val: Optional[Any] = None) -> None:
"""Trains the Transformed Outcome model by first fitting a propensity model, retrieving the propensity scores for each instance,
computing the transformed outcomes, and finally fitting a regressor on the transformed outcomes.
Args:
df_train (pyspark.sql.DataFrame): a dataframe containing the treatment indicators, the observed outcomes, and predictors
df_val (pyspark.sql.DataFrame): a dataframe containing the treatment indicators, the observed outcomes, and predictors
"""
self.propensity_estimator.fit(df_train)
df_train = self._get_transformed_outcomes(df_train)
self.model = self.model.fit(df_train)
def predict(self, df: pyspark.sql.DataFrame) -> pyspark.sql.DataFrame:
"""Applies the Transformed Outcome Estimator and returns treatment effect predictions.
Args:
df (pyspark.sql.DataFrame): a dataframe containing predictors
Returns:
df (pyspark.sql.DataFrame): a dataframe containing treatment effect predictions
"""
df_cols = df.columns
df = self._get_transformed_outcomes(df)
df = self.model.transform(df)
split_udf = udf(lambda value: value, FloatType())
pred_col = "prediction"
df = df.withColumn(self.output_colname, split_udf(pred_col))
df = df.select([*df_cols, self.output_colname])
return df
def _get_transformed_outcomes(self, df: pyspark.sql.DataFrame) -> pyspark.sql.DataFrame:
"""Applies the propensity model, computes and returns the transformed outcomes.
Args:
df (pyspark.sql.DataFrame): a dataframe containing the treatment indicators, the observed outcomes, and predictors
Returns:
df (pyspark.sql.DataFrame): a dataframe containing the transformed outcomes
"""
df = self.propensity_estimator.predict(df)
df = df.withColumn(
"D",
F.when(
F.col(self.treatment_colname) == self.treatment_value, F.col(self.target_colname) / F.col("propensity")
).otherwise(-1.0 * F.col(self.target_colname) / (1 - F.col("propensity"))),
)
return df
class PropensityEstimator:
"""Estimates treatment propensities, either as the simple treatment proportions E[T] or by training a model for E[T | X]."""
def __init__(
self,
base_model_class: Any = None,
base_model_params: Dict = None,
predictors_colname: str = None,
treatment_colname: str = "treatment",
treatment_value: int = 1,
control_value: int = 0,
output_colname: str = "propensity",
):
"""Initializes the propensity model.
Args:
base_model_class (pyspark.ml, optional): the model class to instantiate the propensity model. If None, propensity will be estimated as the overall proportion of treated users in the training data.
base_model_params (dict, optional): parameters and their values for the model. Not used if <base_model_class> is None.
predictors_colname (list of str, optional): the column names that contain the predictor variables. Not used if <base_model_class> is None.
treatment_colname (str, optional): the column name that contains the treatment indicators
treatment_value (str or int, optional): the value in column <treatment_colname> that refers to the treatment group
output_colname (str, optional): the column name for the estimator output
"""
if base_model_class is not None:
base_model_params["featuresCol"] = predictors_colname # type: ignore
base_model_params["labelCol"] = treatment_colname # type: ignore
self.model = base_model_class(**base_model_params)
self.predictors_colname = predictors_colname
else:
self.model = None
self.propensity = 0.5
self.treatment_colname = treatment_colname
self.treatment_value = treatment_value
self.control_value = control_value
self.output_colname = output_colname
def fit(self, df_train: pyspark.sql.DataFrame, df_val: Optional[Any] = None) -> None:
"""Fits a propensity model.
If self.model is None, uses the proportion of treated instances in df_train to estimate E[T], independent of X.
If self.model is instantiated, fits a full propensity model E[T | X].
Args:
df_train (pyspark.sql.DataFrame): a dataframe containing the treatment indicators and predictors
df_val (pyspark.sql.DataFrame): a dataframe containing the treatment indicators and predictors
"""
if self.model is not None:
self.model = self.model.fit(df_train)
def predict(self, df: pyspark.sql.DataFrame) -> pyspark.sql.DataFrame:
"""Applies the propensity model and returns treatment assignment predictions.
If self.model is None, uses the pre-calculated treatment proportion for all instances.
If self.model is instantiated, applies the model to get estimates E[T | X].
Args:
df (pyspark.sql.DataFrame): a dataframe containing predictors
Returns:
df (pyspark.sql.DataFrame): a dataframe containing treatment assignment predictions
"""
df_cols = df.columns
if self.model is None:
treat_count = df.where(F.col(self.treatment_colname) == self.treatment_value).count()
control_count = df.where(F.col(self.treatment_colname) == self.control_value).count()
df = df.withColumn(
self.output_colname,
F.when(
F.col(self.treatment_colname) == self.treatment_value,
F.lit(treat_count / (treat_count + control_count)),
).otherwise(F.lit(control_count / (treat_count + control_count))),
)
else:
df = self.model.transform(df)
split_udf = udf(lambda value: value[1].item(), FloatType())
df = df.withColumn(self.output_colname, split_udf("probability"))
df = df.select([*df_cols, self.output_colname])
return df
class RetrospectiveEstimator:
"""Estimates E[T | Y=1, X], which corresponds to estimating the relative treatment effect E[Y | T=1, X] / E[Y | T=0, X] in case of 50-50 treatment vs. control RCT data.
This estimator can also used as the greedy solution for maximizing incrementality under ROI constraints, as described in Goldenberg et al. (2020) (preprint: https://drive.google.com/file/d/1E0KQ_sT09q1bpnlt9gZFFSbrx-YgGcqF/view).
"""
def __init__(
self,
base_model_class: Any,
base_model_params: Dict,
predictors_colname: str = "features",
treatment_colname: str = "treatment",
target_colname: str = "outcome",
positive_outcome_value: int = 1,
output_colname: str = "score",
):
"""Initializes the Retrospective Estimator.
Args:
base_model_class (pyspark.ml): the model class to instantiate the Retrospective Estimator with
base_model_params (dict): parameters and their values for the model
predictors_colname (str, optional): the column names that contain the predictor variables
treatment_colname (str, optional): the column name that contains the treatment indicators
target_colname (str, optional): the column name that contains the target
positive_outcome_value (str or int, optional): the value in column <target_colname> that refers to the positive outcome
output_colname (str, optional): the column name for the estimator output
"""
base_model_params["featuresCol"] = predictors_colname
base_model_params["labelCol"] = treatment_colname
self.model = base_model_class(**base_model_params)
self.predictors_colname = predictors_colname
self.treatment_colname = treatment_colname
self.target_colname = target_colname
self.positive_outcome_value = positive_outcome_value
self.output_colname = output_colname
def fit(self, df_train: pyspark.sql.DataFrame, df_val: Optional[Any] = None) -> None:
"""Trains the Retrospective Estimator E[T | Y=1, X].
Args:
df_train (pyspark.sql.DataFrame): a dataframe containing the treatment indicators, the observed outcomes, and predictors
df_val (pyspark.sql.DataFrame): a dataframe containing the treatment indicators, the observed outcomes, and predictors
"""
self.model = self.model.fit(df_train.where(F.col(self.target_colname) == self.positive_outcome_value))
def predict(self, df: pyspark.sql.DataFrame) -> pyspark.sql.DataFrame:
"""Applies the Retrospective Estimator model and returns predictions for E[T | Y=1, X].
Args:
df (pyspark.sql.DataFrame): a dataframe containing predictors
Returns:
df (pyspark.sql.DataFrame): a dataframe containing predictions for E[T | Y=1, X]
"""
df_cols = df.columns
df = self.model.transform(df)
if "probability" not in df.columns:
split_udf = udf(lambda value: value, FloatType())
pred_col = "prediction"
else:
split_udf = udf(lambda value: value[1].item(), FloatType())
pred_col = "probability"
df = df.withColumn(self.output_colname, split_udf(pred_col))
df = df.select([*df_cols, self.output_colname])
return df
|
1680457
|
from __future__ import annotations
import contextlib
import warnings
from abc import ABCMeta, abstractmethod
from functools import partial as Partial
from types import MethodType
from typing import Any, Callable, Iterable, TypeVar
import torch
from torch import Tensor, nn
from torch.optim import Optimizer
from torch.optim.lr_scheduler import _LRScheduler as Scheduler
from torch.utils.data import DataLoader
from homura import get_global_rank, get_local_rank, is_distributed, is_master
from homura.liblog import get_logger, set_tqdm_stdout_stderr, set_verb_level, tqdm
from .metrics import accuracy
from .optim import LARC
from .reporters import ReporterList, TQDMReporter, _ReporterBase
from .utils._mixin import StateDictMixIn
from .utils.containers import StepDict, TensorTuple
__all__ = ["TrainerBase", "SupervisedTrainer"]
DataType = TypeVar('DataType', Tensor, tuple[Tensor, ...])
class TrainerBase(StateDictMixIn, metaclass=ABCMeta):
""" Baseclass for Trainers
:param model: model to be trained
:param optimizer: optimizer for the model
:param loss_f: loss function for training
:param reporters: list of reporters
:param scheduler: learning rate scheduler
:param device: device to be used
:param quiet: True to disable tqdm
:param disable_cudnn_benchmark: True to disable cudnn benchmark mode
:param disable_cuda_nonblocking: True to disable cuda nonblocking
:param logger: optional logger
:param use_sync_bn: True to convert BN to sync BN
:param tqdm_ncols: number of columns of tqdm
:param kwargs:
"""
def __init__(self,
model: nn.Module or dict[str, nn.Module],
optimizer: Partial or Optimizer or dict[str, Optimizer],
loss_f: Callable or dict[str, Callable] = None,
*,
reporters: _ReporterBase or list[_ReporterBase] = None,
scheduler: Partial or Scheduler or dict[str, Scheduler] = None,
device: torch.device or str = None,
quiet: bool = False,
disable_cudnn_benchmark: bool = False,
disable_cuda_nonblocking: bool = False,
logger=None,
use_sync_bn: bool = False,
tqdm_ncols: int = 120,
debug: bool = False,
profile: bool = False,
dist_kwargs: dict = None,
prof_kwargs: dict = None,
disable_auto_ddp: bool = False,
**kwargs):
if kwargs.get("update_scheduler_by_epoch"):
raise DeprecationWarning("update_scheduler_by_epoch is deprecated, users need to step")
if kwargs.get("callbacks"):
raise DeprecationWarning("callback is deprecated, if you need, use homura before v2020.8")
self.logger = logger or get_logger(__name__)
self.device = device or (torch.device("cuda") if torch.cuda.is_available() else torch.device("cpu"))
self._is_debug = debug
if self._is_debug:
self.logger.warning("Trainer is set to be debug mode, which may affect the performance")
set_verb_level("debug")
# setup for distributed
self._use_sync_bn = use_sync_bn
if is_distributed():
if self._use_sync_bn:
model = nn.SyncBatchNorm.convert_sync_batchnorm(model)
(self.logger.info if is_master() else self.logger.debug)(
"BNs of model are converted to nn.SyncBatchNorm")
rank = get_local_rank()
torch.cuda.set_device(rank)
if get_global_rank() > 0:
# to avoid overwriting
quiet = True
self.loss_f = loss_f
self._verbose = not quiet
# setup model
if isinstance(model, nn.Module):
self.model = model
elif isinstance(model, dict):
self.model = nn.ModuleDict(model)
self.logger.debug(f"model is nn.ModuleDict of {self.model.keys()}")
else:
raise TypeError(f"Unknown type for `model`. Expected nn.Module or dict[str, Module], but got {type(model)}")
if "cuda" in str(self.device):
if not disable_auto_ddp:
self.model.to(self.device)
torch.backends.cudnn.benchmark = not disable_cudnn_benchmark
self._cuda_nonblocking = not disable_cuda_nonblocking
self.logger.debug(f"cuda: True, cudnn.benchmark: {not disable_cudnn_benchmark}, "
f"cuda.nonblocking: {not disable_cuda_nonblocking}")
else:
self._cuda_nonblocking = False
# usually, this is not expected
self.logger.info(f"cuda: False (torch.cuda.is_available()={torch.cuda.is_available()})")
if is_distributed() and not disable_auto_ddp:
dist_kwargs = dist_kwargs or {}
self.model = nn.parallel.DistributedDataParallel(self.model, device_ids=[rank], **dist_kwargs)
self.logger.debug(f"model converted to DistributedDataParallel at rank={rank}")
# self.accessible_model is useful for e.g., checkpointing
if isinstance(self.model, nn.parallel.DistributedDataParallel) or isinstance(self.model, nn.DataParallel):
self.accessible_model = self.model.module
else:
self.accessible_model = self.model
if disable_auto_ddp:
self.logger.info("self.accessible_model need to be set manually")
self.optimizer = optimizer
self.scheduler = scheduler
self.reporter = None
# called via property
# _step and _epoch are set to -1 because they are incremented before each iteration and epoch
self._step = -1
self._epoch = -1
self._is_train = True
# to nest, leave=False (https://github.com/tqdm/tqdm/blob/master/examples/simple_examples.py#L19)
self._tqdm = lambda x: x
if self.verbose:
self._tqdm = Partial(tqdm, ncols=tqdm_ncols, leave=False)
set_tqdm_stdout_stderr()
self.logger.debug("verbose: setup tqdm")
else:
self.logger.debug("quiet: no tqdm")
# this needs to be here to access members from set_*,
for k, v in kwargs.items():
if hasattr(self, k):
raise AttributeError(f"{self} already has {k}")
if isinstance(v, torch.Tensor):
v = v.to(self.device)
if isinstance(v, nn.Module):
v.to(self.device)
setattr(self, k, v)
self.logger.debug(f"trainer sets {k} as a new attribute")
# setup optimizer and scheduler
self.set_optimizer()
self.set_scheduler()
if reporters is not None and not isinstance(reporters, Iterable):
reporters = [reporters]
reporters = reporters or []
if not any([isinstance(rep, TQDMReporter) for rep in reporters]):
# if reporters not contain TQDMReporter
reporters.append(TQDMReporter(ncols=tqdm_ncols))
self.logger.debug(f"reporter is ready: {reporters}")
self.reporter = ReporterList(reporters)
if profile:
default_prof_kwargs = dict(activities=[torch.profiler.ProfilerActivity.CPU,
torch.profiler.ProfilerActivity.CUDA],
schedule=torch.profiler.schedule(wait=1, warmup=1, active=10),
on_trace_ready=torch.profiler.tensorboard_trace_handler("./profile"),
with_stack=True)
prof_kwargs = prof_kwargs or default_prof_kwargs
self._profile_cm = torch.profiler.profile(**prof_kwargs)
self.logger.warning("profiler is activated")
else:
class Dummy:
def step(self): ...
self._profile_cm = contextlib.nullcontext(Dummy())
def tqdm(self,
iter: Iterable
) -> Iterable:
return self._tqdm(iter)
@property
def verbose(self
) -> bool:
return self._verbose
@property
def step(self
) -> int:
return self._step
@property
def epoch(self
) -> int:
return self._epoch
@property
def is_train(self
) -> bool:
return self._is_train
@property
def history(self
) -> dict[str, list[float]]:
return self.reporter.history
@abstractmethod
def iteration(self,
data: DataType
) -> None:
# Iteration
pass
def override_iteration(self,
new_iteration: Callable[[DataType], None]
) -> None:
""" Override iteration method ::
def new_iteration(trainer, data):
input, target = data
...
results.loss = loss
return results
trainer.update_iteration(new_iteration)
:param new_iteration:
:return:
"""
setattr(self, "iteration", MethodType(new_iteration, self))
self.logger.debug("Override iteration")
def epoch_range(self,
epoch: int
) -> TQDMReporter:
tqdm_reporter = [rep for rep in self.reporter.reporters if isinstance(rep, TQDMReporter)][0]
tqdm_reporter.set_iterator(range(epoch))
return tqdm_reporter
def infer_batch_size(self,
data: DataType
) -> int:
if isinstance(data, Tensor):
batch_size = data.size(0)
else:
batch_size = data[0].size(0)
return batch_size
def _iteration(self,
data: DataType,
mode: str
) -> None:
""" Iteration level training loop
:param data: should be TensorTuple
:param mode: train, test or val
:return:
"""
data = self.data_preprocess(data)
batch_size = self.infer_batch_size(data)
self.reporter.set_batch_size(batch_size)
if self._is_debug and batch_size == 1 and self.is_train:
if any([isinstance(m, nn.modules.batchnorm._BatchNorm) for m in self.accessible_model.modules()]):
warnings.warn("BatchNorm exists, while batch size is 1", RuntimeWarning)
with torch.autograd.set_detect_anomaly(self._is_debug) and self._profile_cm as p:
self.iteration(data)
p.step()
def __enter__(self):
"""
>>> with TrainerBase(...) as trainer:
>>> trainer.train(...)
"""
return self
def __exit__(self, exc_type, exc_val, exc_tb):
self.exit()
def _loop(self,
data_loader: Iterable or DataLoader,
mode: str
) -> None:
for data in self.tqdm(data_loader):
if self.is_train:
# increment step here for `callbacks`
self._step += 1
self._iteration(data, mode)
self.reporter.report(self.epoch, mode)
self.logger.debug(f"epoch {self.epoch} finished")
def data_preprocess(self,
data: DataType
) -> DataType:
return TensorTuple(data).to(self.device, non_blocking=self._cuda_nonblocking)
def train(self,
data_loader: Iterable or DataLoader,
mode: str = "train"
) -> None:
""" Training the model for an epoch.
:param data_loader:
:param mode: Name of this loop. Default is `train`. Passed to callbacks.
"""
self._is_train = True
self._epoch += 1
# For distributed training
if isinstance(data_loader, DataLoader) and hasattr(data_loader.sampler, "set_epoch"):
data_loader.sampler.set_epoch(self.epoch)
self.logger.debug("set_epoch to the sampler")
self.model.train()
if hasattr(self.loss_f, "train"):
self.loss_f.train()
self._loop(data_loader, mode=mode)
if self._is_debug:
for name, param in self.accessible_model.named_parameters():
self.reporter.add_histogram(name, param, self.epoch)
def test(self,
data_loader: Iterable or DataLoader,
mode: str = "test"
) -> None:
""" Evaluate the model.
:param data_loader:
:param mode: Name of this loop. Default is `test`. Passed to callbacks.
:return:
"""
self._is_train = False
self.model.eval()
if hasattr(self.loss_f, "eval"):
self.loss_f.eval()
with torch.no_grad():
self._loop(data_loader, mode=mode)
def run(self,
train_loader: Iterable or DataLoader,
val_loaders: Iterable or DataLoader or dict[str, Iterable or DataLoader],
total_iterations: int,
val_intervals: int
) -> None:
""" Train the model for a given iterations. This module is almost equal to ::
for ep in range(total_iterations):
trainer.train(train_loader)
for k, v in val_loaders.items():
trainer.test(v, k)
:param train_loader:
:param val_loaders:
:param total_iterations:
:param val_intervals:
:return:
"""
class ProxyLoader(object):
def __init__(self, loader):
self.loader = loader
self._epoch = 0
def __len__(self):
return val_intervals
def __iter__(self):
counter = 0
while True:
for data in self.loader:
if counter == val_intervals:
return # from python 3.7, this is valid
yield data
counter += 1
self._epoch += 1
if hasattr(self.loader, 'sampler') and hasattr(self.loader.sampler, 'set_epoch'):
self.loader.sampler.set_epoch(self._epoch)
train_loader = ProxyLoader(train_loader)
if not isinstance(val_loaders, dict) and (isinstance(val_loaders, Iterable) or
isinstance(val_loaders, DataLoader)):
val_loaders = {'val': val_loaders}
for ep in self.epoch_range(total_iterations // val_intervals):
self.train(train_loader)
for name, loader in val_loaders.items():
self.test(loader, name)
def exit(self):
self.reporter.exit()
def set_optimizer(self
) -> None:
""" Set optimizer(s) for model(s). You can override as::
class YourTrainer(TrainerBase):
def set_optimizer(self):
self.optimizer = torch.optim.SGD(self.model.parameters())
:return:
"""
optimizer = self.optimizer
if isinstance(optimizer, Optimizer) or optimizer is None:
self.optimizer = optimizer
elif isinstance(optimizer, Partial):
if not issubclass(optimizer.func, Optimizer):
raise TypeError(f"`optimizer.func` is expected to be subclass of `Optimizer`"
f" but got {type(optimizer.func)}")
self.optimizer = optimizer(self.model.parameters())
elif isinstance(optimizer, dict):
if not isinstance(self.model, nn.ModuleDict):
raise TypeError("When `optimizer` is `dict`, `model` also needs to be `dict` or `nn.ModuleDict`")
if isinstance(list(optimizer.values())[0], Partial):
optimizer = {k: v(self.model[k].parameters()) for k, v in optimizer.items() if v is not None}
self.optimizer = StepDict(Optimizer, **optimizer)
else:
raise TypeError(f"Unexpected type {type(optimizer)} for `optimizer`")
def set_scheduler(self
) -> None:
""" Set scheduler(s) for optimizer(s). You can override as ::
class YourTrainer(TrainerBase):
def set_scheduler(self):
self.scheduler = torch.optim.lr_scheduler.Foo(self.optimizer)
:return:
"""
scheduler = self.scheduler
if scheduler is not None and self.optimizer is None:
raise TypeError("Optimizer is not set, so scheduler cannot be set")
if isinstance(scheduler, Scheduler) or scheduler is None:
self.scheduler = scheduler
elif isinstance(scheduler, Partial):
self.scheduler = scheduler(self.optimizer)
elif isinstance(scheduler, dict):
if not isinstance(self.optimizer, StepDict):
raise TypeError("When `scheduler` is `dict`, `optimizer` is also needs to be `dict`")
_scheduler = {}
for k, v in scheduler.items():
if isinstance(v, Partial):
v = v(self.optimizer[k])
_scheduler[k] = v
self.scheduler = StepDict(Scheduler, **_scheduler)
else:
raise TypeError(f"Unexpected type {type(scheduler)} for `scheduler`")
if self.verbose and hasattr(self.scheduler, 'verbose'):
self.scheduler.verbose = True
class SupervisedTrainer(TrainerBase):
""" A simple trainer for supervised image classification. It only accepts single model. AMP-ready.
"""
def __init__(self,
model: nn.Module,
optimizer: Optimizer,
loss_f: Callable,
*,
reporters: _ReporterBase or list[_ReporterBase] = None,
scheduler: Scheduler = None,
quiet=False,
disable_cudnn_benchmark=False,
data_parallel=False,
use_amp=False,
use_channel_last=False,
report_accuracy_topk: int or list[int] = None,
update_scheduler_iter: bool = False,
use_larc: bool = False,
grad_accum_steps: int = None,
**kwargs):
if isinstance(model, dict):
raise TypeError(f"{type(self)} does not support dict model")
self.use_larc = use_larc
super(SupervisedTrainer, self).__init__(model, optimizer, loss_f, reporters=reporters, scheduler=scheduler,
quiet=quiet, disable_cudnn_benchmark=disable_cudnn_benchmark,
**kwargs)
if data_parallel and not isinstance(self.model, nn.DataParallel) and torch.cuda.device_count() > 1:
self.model = nn.DataParallel(self.model)
self.model.to(self.device)
self.logger.info("model converted to DataParallel")
self._use_amp = use_amp
self.scaler = torch.cuda.amp.GradScaler(enabled=self._use_amp)
if self._use_amp:
(self.logger.info if is_master() else self.logger.debug)("AMP is activated")
self._use_channel_last = use_channel_last
if self._use_channel_last:
self.logger.warning("channel_last format is an experimental feature")
self.model = self.model.to(memory_format=torch.channels_last)
if report_accuracy_topk is not None:
if not isinstance(report_accuracy_topk, Iterable):
report_accuracy_topk = [report_accuracy_topk]
report_accuracy_topk = [k for k in report_accuracy_topk if k != 1]
self._report_topk = report_accuracy_topk
self.update_scheduler_iter = update_scheduler_iter & (scheduler is not None)
if self.update_scheduler_iter:
self.logger.info("scheduler is set to be updated after every iteration")
else:
self.logger.debug("self.update_scheduler_iter=False. Update scheduler manually")
if grad_accum_steps is not None and grad_accum_steps <= 1:
raise ValueError('grad_accum_steps should be equal or larger than 2.')
self.grad_accum_steps = 1 if grad_accum_steps is None else grad_accum_steps
if self.grad_accum_steps > 1:
self.logger.info('Gradient accumulation is activated')
def iteration(self,
data: tuple[Tensor, Tensor]
) -> None:
input, target = data
if self.is_train:
loss = 0
for input, target in zip(input.chunk(self.grad_accum_steps), target.chunk(self.grad_accum_steps)):
with torch.cuda.amp.autocast(self._use_amp):
output = self.model(input)
_loss = self.loss_f(output, target) / self.grad_accum_steps
loss += _loss.detach()
# this code supports both AMP and non AMP
self.scaler.scale(_loss).backward()
self.scaler.step(self.optimizer)
self.scaler.update()
self.optimizer.zero_grad()
if self.update_scheduler_iter:
self.scheduler.step()
else:
# test time
with torch.cuda.amp.autocast(self._use_amp):
output = self.model(input)
loss = self.loss_f(output, target)
if self._is_debug and torch.isnan(loss):
self.logger.warning("loss is NaN")
self.reporter.add('accuracy', accuracy(output, target))
self.reporter.add('loss', loss.detach_())
if self._report_topk is not None:
for top_k in self._report_topk:
self.reporter.add(f'accuracy@{top_k}', accuracy(output, target, top_k))
def data_preprocess(self,
data: tuple[Tensor, Tensor]
) -> tuple[Tensor, Tensor]:
input, target = data
return (input.to(self.device, non_blocking=self._cuda_nonblocking,
memory_format=torch.channels_last if self._use_channel_last
else torch.preserve_format),
target.to(self.device, non_blocking=self._cuda_nonblocking))
def state_dict(self
) -> dict[str, Any]:
return {'model': self.accessible_model.state_dict(),
'optim': self.optimizer.state_dict(),
'scheduler': self.scheduler.state_dict(),
'epoch': self.epoch,
'use_sync_bn': self._use_sync_bn,
'use_amp': self._use_amp}
def load_state_dict(self,
state_dict: dict[str, Any]
) -> None:
self.accessible_model.load_state_dict(state_dict['model'])
self.optimizer.load_state_dict(state_dict['optim'])
self.scheduler.load_state_dict(state_dict['scheduler'])
self.scheduler.last_epoch = state_dict['epoch']
self._epoch = state_dict['epoch']
self._use_sync_bn = state_dict['use_sync_bn']
self._use_amp = state_dict['use_amp']
def set_scheduler(self
) -> None:
super().set_scheduler()
if self.use_larc:
# scheduler expects optimizer is Optimizer, but LARC is not
self.optimizer = LARC(self.optimizer)
|
1680459
|
from unetpp import model as unetpp
from unet import model as unet
from tensorflow.keras.optimizers import Adam
from losses import dice, iou, weighted_loss, cce_iou_dice
weights_list = {1: 1.0, 2: 50.0, 3: 70.0}
if __name__ == '__main__':
optimizer = Adam(lr=0.0005)
unet.compile(optimizer=optimizer, loss=weighted_loss(cce_iou_dice, weights_list), metrics=[dice, iou])
unet.summary()
unetpp.compile(optimizer=optimizer, loss=weighted_loss(cce_iou_dice, weights_list), metrics=[dice, iou])
unetpp.summary()
|
1680518
|
import abc
import json
import logging
import sys
import typing
import sh
from kubeyard.commands.devel import BaseDevelCommand
logger = logging.getLogger(__name__)
class TestCommand(BaseDevelCommand):
"""
Runs tests in docker image built by build command. Can be overridden in <project_dir>/sripts/test.
Supported databases:
- Postgres
- CockroachDB
You can override migration command and test command passed to docker container with code.
\b
Example:
test_migration_command: migrate_user
test_command: db_tests_for_user
If kubeyard is set up in development mode it uses minikube as docker host and mounts volumes configured in
dev_mounted_paths in config/kubeyard.yml if they have mount-in-test set.
\b
Example:
dev_mounted_paths:
- name: dev-volume
host-path: docker/source
mount-in-tests:
path: /package
image-name: sw-project
You can setup database before tests
(on dev environment db will be cached, otherwise it will be removed immediately after tests).
\b
Example:
tests_with_database: true
test_database_type: postgres <- Available types: `postgres`, `cockroach`. `postgres` is default.
test_database_image: postgres:10.3
test_database_name: test
"""
custom_script_name = 'test'
context_vars = ["force_recreate_database", "force_migrate_database"]
def __init__(self, *, force_recreate_database, force_migrate_database, test_options, **kwargs):
super().__init__(**kwargs)
self.test_options = test_options
self.force_recreate_database = force_recreate_database
self.force_migrate_database = force_migrate_database
@property
def args(self) -> list:
return list(self.test_options)
def run_default(self):
if self.context.get('TESTS_WITH_DATABASE'):
database_class = DATABASE_MAP[self.context.get("TEST_DATABASE_TYPE", "postgres")]
with database_class(
is_development=self.is_development,
volumes=self.volumes,
context=self.context, tag=self.tag,
tested_image_name=self.image,
force_recreate=self.force_recreate_database,
force_migrate=self.force_migrate_database,
) as database:
self.run_tests(database)
else:
self.run_tests()
def run_tests(self, database: 'Database' = None):
logger.info('Running tests...')
try:
sh.docker.run.bake(
rm=True,
_out=sys.stdout.buffer,
_err=sys.stdout.buffer,
net=database.network if database else 'none',
)(
*self.volumes,
self.image,
self.context['TEST_COMMAND'],
*self.test_options,
)
except sh.ErrorReturnCode_1 as e:
logger.debug(e)
sys.exit(1)
class Database(metaclass=abc.ABCMeta):
def __init__(
self,
is_development: bool,
volumes: typing.Iterable[str],
context: dict, tag: str,
tested_image_name: str,
force_recreate: bool = False,
force_migrate: bool = False,
):
self.is_development = is_development
self.volumes = volumes
self.context = context
self.tag = tag
self.tested_image_name = tested_image_name
self.force_migrate = force_migrate
self.force_recreate = force_recreate
self._migrated = False
def __enter__(self):
if not self.is_development or self.force_recreate:
self.remove_database()
if self.container_stopped:
logger.info("Found stopped DB, restarting it!")
sh.docker.start(self.container_name)
if not self.already_up:
self.create()
self.wait_until_ready()
self.migrate()
if self.force_migrate:
self.migrate()
return self
def __exit__(self, exc_type, exc_val, exc_tb):
if not self.is_development:
self.remove_database()
@property
def container_stopped(self) -> bool:
try:
container_info = json.loads(str(sh.docker.inspect(self.container_name)))
except sh.ErrorReturnCode_1:
return False
else:
return container_info[0]['State']['Running'] is False
@property
def already_up(self) -> bool:
try:
sh.docker.inspect(self.container_name)
return True
except sh.ErrorReturnCode_1:
return False
@property
def container_name(self) -> str:
image_name = self.context['DOCKER_IMAGE_NAME']
return f'db-test-{image_name}-{self.tag}'
def remove_database(self):
logger.info('Removing database...')
try:
sh.docker.rm.bake(
force=True,
volumes=True,
)(
self.container_name,
)
except sh.ErrorReturnCode_1 as e:
logger.info('Database does not exist yet.')
logger.debug(e)
@abc.abstractmethod
def create(self):
raise NotImplementedError
def wait_until_ready(self):
logger.info('Waiting for database...')
for log in sh.docker.logs.bake(follow=True, _err_to_out=True, _iter='out')(self.container_name):
if self.started_log in log:
logger.info('Database ready!')
break
@property
@abc.abstractmethod
def started_log(self):
raise NotImplementedError
def migrate(self):
if not self._migrated:
logger.info('Running migrations...')
sh.docker.run.bake(
net=self.network,
rm=True,
_err_to_out=True,
)(
*self.volumes,
self.tested_image_name,
self.context['TEST_MIGRATION_COMMAND'],
)
logger.info('Migrations done!')
self._migrated = True
@property
def network(self) -> str:
return f'container:{self.container_name}'
class PostgresDatabase(Database):
started_log = 'PostgreSQL init process complete; ready for start up.'
def create(self):
logger.info('Setting up database...')
sh.docker.run.bake(
restart='always',
net='none',
name=self.container_name,
detach=True,
e='POSTGRES_DB={}'.format(self.context['TEST_DATABASE_NAME']),
)(
self.context['TEST_DATABASE_IMAGE'],
)
class CockroachDatabase(Database):
started_log = 'initialized new cluster'
def create(self):
logger.info('Releasing cockroaches...')
sh.docker.run.bake(
restart='always',
net='none',
name=self.container_name,
detach=True,
)(
self.context['TEST_DATABASE_IMAGE'],
'start',
'--insecure',
'--host=localhost',
'--logtostderr',
)
self._create_database()
def _create_database(self):
self.wait_until_ready()
sh.docker.run.bake(
net=self.network,
rm=True,
)(
self.context["TEST_DATABASE_IMAGE"],
"sql",
"--insecure",
"-e",
"CREATE DATABASE {}".format(self.context['TEST_DATABASE_NAME']),
)
DATABASE_MAP = {
'postgres': PostgresDatabase,
'cockroach': CockroachDatabase,
}
|
1680584
|
import torch
import torch.nn as nn
import torch.nn.functional as F
from torch.nn import init
from operations import *
from torch.autograd import Variable
from genotypes import PRIMITIVES
import numpy as np
from thop import profile
from matplotlib import pyplot as plt
from thop import profile
from analytical_model.analytical_prediction import search_for_best_latency, evaluate_latency
class MixedOp(nn.Module):
def __init__(self, C_in, C_out, op_idx, quant_idx, layer_id, stride=1, num_bits_list=[32]):
super(MixedOp, self).__init__()
self.layer_id = layer_id
self._op = OPS[PRIMITIVES[op_idx]](C_in, C_out, layer_id, stride)
if type(num_bits_list) == list:
self.num_bits = num_bits_list[quant_idx[op_idx]]
else:
self.num_bits = num_bits_list
def forward(self, x):
return self._op(x, num_bits=self.num_bits)
def forward_flops(self, size):
# int: force #channel; tensor: arch_ratio; float(<=1): force width
flops, size_out = self._op.forward_flops(size)
return flops, size_out
def forward_bitops(self, size):
flops, size_out = self._op.forward_flops(size)
bitops = flops * self.num_bits * self.num_bits
return bitops, size_out
class FBNet_Infer(nn.Module):
def __init__(self, alpha, beta, config):
super(FBNet_Infer, self).__init__()
self.op_idx_list = F.softmax(alpha, dim=-1).argmax(-1)
self.quant_idx_list = F.softmax(beta, dim=-1).argmax(-1)
self.num_classes = config.num_classes
self.num_layer_list = config.num_layer_list
self.num_channel_list = config.num_channel_list
self.stride_list = config.stride_list
self.num_bits_list = config.num_bits_list
self.stem_channel = config.stem_channel
self.header_channel = config.header_channel
if config.dataset == 'imagenet':
stride_init = 2
else:
stride_init = 1
self.stem = ConvNorm(3, self.stem_channel, kernel_size=3, stride=stride_init, padding=1, bias=False)
self.cells = nn.ModuleList()
layer_id = 1
for stage_id, num_layer in enumerate(self.num_layer_list):
for i in range(num_layer):
if i == 0:
if stage_id == 0:
op = MixedOp(self.stem_channel, self.num_channel_list[stage_id], self.op_idx_list[layer_id-1], self.quant_idx_list[layer_id-1], layer_id, stride=self.stride_list[stage_id], num_bits_list=self.num_bits_list)
else:
op = MixedOp(self.num_channel_list[stage_id-1], self.num_channel_list[stage_id], self.op_idx_list[layer_id-1], self.quant_idx_list[layer_id-1], layer_id, stride=self.stride_list[stage_id], num_bits_list=self.num_bits_list)
else:
op = MixedOp(self.num_channel_list[stage_id], self.num_channel_list[stage_id], self.op_idx_list[layer_id-1], self.quant_idx_list[layer_id-1], layer_id, stride=1, num_bits_list=self.num_bits_list)
layer_id += 1
self.cells.append(op)
self.header = ConvNorm(self.num_channel_list[-1], self.header_channel, kernel_size=1)
self.avgpool = nn.AdaptiveAvgPool2d(1)
self.fc = nn.Linear(self.header_channel, self.num_classes)
self._criterion = nn.CrossEntropyLoss()
self.init_params()
def init_params(self):
for m in self.modules():
if isinstance(m, nn.Conv2d):
init.kaiming_normal_(m.weight, mode='fan_out')
if m.bias is not None:
init.constant_(m.bias, 0)
elif isinstance(m, nn.BatchNorm2d):
init.constant_(m.weight, 1)
init.constant_(m.bias, 0)
elif isinstance(m, nn.Linear):
init.normal_(m.weight, std=0.001)
if m.bias is not None:
init.constant_(m.bias, 0)
def forward(self, input):
out = self.stem(input)
for i, cell in enumerate(self.cells):
out = cell(out)
out = self.fc(self.avgpool(self.header(out)).view(out.size(0), -1))
return out
def forward_flops(self, size):
flops_total = []
flops, size = self.stem.forward_flops(size)
flops_total.append(flops)
for i, cell in enumerate(self.cells):
flops, size = cell.forward_flops(size)
flops_total.append(flops)
flops, size = self.header.forward_flops(size)
flops_total.append(flops)
return sum(flops_total)
def forward_bitops(self, size):
bitops_total = []
flops, size = self.stem.forward_flops(size)
bitops_total.append(flops*8*8)
for i, cell in enumerate(self.cells):
bitops, size = cell.forward_bitops(size)
bitops_total.append(bitops)
flops, size = self.header.forward_flops(size)
bitops_total.append(flops*8*8)
return sum(bitops_total)
def _loss(self, input, target):
logit = self(input)
loss = self._criterion(logit, target)
return loss
def eval_latency(self, cifar=True, iteration=10000, mode='random', fix_comp_mode=True, temp=1, hardware=None):
block_info = [PRIMITIVES[op_id] for op_id in self.op_idx_list]
if type(self.num_bits_list) == list:
quant_idx_list_layerwise = [self.quant_idx_list[layer_id][self.op_idx_list[layer_id]] for layer_id in range(len(self.op_idx_list))]
quant_info = [self.num_bits_list[bit_id] for bit_id in quant_idx_list_layerwise]
else:
quant_info = [self.num_bits_list for _ in range(len(self.op_idx_list))]
self.num_bits_list = [self.num_bits_list]
if hardware is None:
searched_hw, throughput, block_wise_performance = search_for_best_latency(block_info, quant_info, block_options=PRIMITIVES, quant_options=self.num_bits_list,
cifar=cifar, edd=False, iteration=iteration, mode=mode, fix_comp_mode=fix_comp_mode, temp=temp)
else:
throughput, block_wise_performance = evaluate_latency(block_info, quant_info, hardware, cifar=cifar, edd=False)
searched_hw = hardware
return throughput, searched_hw
|
1680591
|
from __future__ import annotations
from typing import TYPE_CHECKING, TypeVar
from qtpy.QtWidgets import QListView
from ._base_item_view import _BaseEventedItemView
from .qt_list_model import QtListModel
if TYPE_CHECKING:
from qtpy.QtWidgets import QWidget
from ...utils.events.containers import SelectableEventedList
ItemType = TypeVar("ItemType")
class QtListView(_BaseEventedItemView[ItemType], QListView):
"""A QListView for a :class:`~napari.utils.events.SelectableEventedList`.
Designed to work with :class:`~napari._qt.containers.QtListModel`.
This class is an adapter between
:class:`~napari.utils.events.SelectableEventedList` and Qt's
`QAbstractItemView` interface (see `Qt Model/View Programming
<https://doc.qt.io/qt-5/model-view-programming.html>`_). It allows python
users to interact with the list in the "usual" python ways, updating any Qt
Views that may be connected, and also updates the python list object if any
GUI events occur in the view.
See docstring of :class:`_BaseEventedItemView` for additional background.
"""
_root: SelectableEventedList[ItemType]
def __init__(
self, root: SelectableEventedList[ItemType], parent: QWidget = None
):
super().__init__(parent)
self.setDragDropMode(QListView.InternalMove)
self.setDragDropOverwriteMode(False)
self.setSelectionMode(QListView.ExtendedSelection)
self.setRoot(root)
def model(self) -> QtListModel[ItemType]:
return super().model()
|
1680596
|
import logging
import math
from typing import Dict
import numpy as np
from pyquaternion import Quaternion
from paralleldomain.utilities.transformation import Transformation
logger = logging.getLogger(__name__)
class CoordinateSystem:
_axis_char_map: Dict[str, np.ndarray] = dict(
**{character: axis for character, axis in zip("FLU", np.identity(3))},
**{character: axis for character, axis in zip("BRD", -np.identity(3))},
)
def __init__(self, axis_directions: str):
self.axis_directions = axis_directions
self._base_matrix = self._create_base_matrix(axis_directions=axis_directions)
@staticmethod
def _create_base_matrix(axis_directions: str) -> np.ndarray:
if len(axis_directions) != 3:
raise ValueError("The axis string needs to have exactly 3 orthogonal values from {RUBLDF}!")
axis_directions = axis_directions.upper()
base_change = np.identity(4)
for i, direction in enumerate(axis_directions):
base_change[:3, i] = CoordinateSystem._axis_char_map[direction]
if np.linalg.det(base_change) == 0.0:
raise ValueError(f"{axis_directions} is not a valid coordinate system!")
return base_change
def __gt__(self, other: "CoordinateSystem") -> Transformation:
return Transformation.from_transformation_matrix(mat=(other._base_matrix.transpose() @ self._base_matrix))
def __lt__(self, other: "CoordinateSystem") -> Transformation:
return other > self
@staticmethod
def get_base_change_from_to(from_axis_directions: str, to_axis_directions: str) -> Transformation:
return CoordinateSystem(from_axis_directions) > CoordinateSystem(to_axis_directions)
@staticmethod
def print_convention():
logger.info(f"Front axis: {CoordinateSystem._axis_char_map['F']}")
logger.info(f"Left axis: {CoordinateSystem._axis_char_map['L']}")
logger.info(f"Up axis: {CoordinateSystem._axis_char_map['U']}")
def quaternion_from_rpy(self, roll: float, pitch: float, yaw: float, degrees: bool = False, order: str = "xyz"):
transform = CoordinateSystem("FLU") > self
front = transform.rotation @ CoordinateSystem._axis_char_map["F"].reshape((3, 1))
left = transform.rotation @ CoordinateSystem._axis_char_map["L"].reshape((3, 1))
up = transform.rotation @ CoordinateSystem._axis_char_map["U"].reshape((3, 1))
rotations = {
"x": Quaternion(axis=front, radians=roll if not degrees else math.radians(roll)),
"y": Quaternion(axis=left, radians=pitch if not degrees else math.radians(pitch)),
"z": Quaternion(axis=up, radians=yaw if not degrees else math.radians(yaw)),
}
q = Quaternion()
for rot in order:
q = q * rotations[rot]
return q
INTERNAL_COORDINATE_SYSTEM = CoordinateSystem("FLU")
|
1680614
|
from autotabular.pipeline.components.base import AutotabularClassificationAlgorithm, IterativeComponentWithSampleWeight
from autotabular.pipeline.constants import DENSE, PREDICTIONS, SPARSE, UNSIGNED_DATA
from autotabular.pipeline.implementations.util import softmax
from autotabular.util.common import check_for_bool
from ConfigSpace.conditions import EqualsCondition, InCondition
from ConfigSpace.configuration_space import ConfigurationSpace
from ConfigSpace.hyperparameters import CategoricalHyperparameter, UniformFloatHyperparameter, UnParametrizedHyperparameter
class SGD(
IterativeComponentWithSampleWeight,
AutotabularClassificationAlgorithm,
):
def __init__(self,
loss,
penalty,
alpha,
fit_intercept,
tol,
learning_rate,
l1_ratio=0.15,
epsilon=0.1,
eta0=0.01,
power_t=0.5,
average=False,
random_state=None):
self.max_iter = self.get_max_iter()
self.loss = loss
self.penalty = penalty
self.alpha = alpha
self.fit_intercept = fit_intercept
self.tol = tol
self.learning_rate = learning_rate
self.l1_ratio = l1_ratio
self.epsilon = epsilon
self.eta0 = eta0
self.power_t = power_t
self.random_state = random_state
self.average = average
self.estimator = None
self.n_iter_ = None
@staticmethod
def get_max_iter():
return 1024
def get_current_iter(self):
return self.n_iter_
def iterative_fit(self, X, y, n_iter=2, refit=False, sample_weight=None):
from sklearn.linear_model import SGDClassifier
# Need to fit at least two iterations, otherwise early stopping will not
# work because we cannot determine whether the algorithm actually
# converged. The only way of finding this out is if the sgd spends less
# iterations than max_iter. If max_iter == 1, it has to spend at least
# one iteration and will always spend at least one iteration, so we
# cannot know about convergence.
if refit:
self.estimator = None
self.n_iter_ = None
if self.estimator is None:
self.fully_fit_ = False
self.alpha = float(self.alpha)
self.l1_ratio = float(self.l1_ratio) if self.l1_ratio is not None \
else 0.15
self.epsilon = float(self.epsilon) if self.epsilon is not None \
else 0.1
self.eta0 = float(self.eta0)
self.power_t = float(self.power_t) if self.power_t is not None \
else 0.5
self.average = check_for_bool(self.average)
self.fit_intercept = check_for_bool(self.fit_intercept)
self.tol = float(self.tol)
self.estimator = SGDClassifier(
loss=self.loss,
penalty=self.penalty,
alpha=self.alpha,
fit_intercept=self.fit_intercept,
max_iter=n_iter,
tol=self.tol,
learning_rate=self.learning_rate,
l1_ratio=self.l1_ratio,
epsilon=self.epsilon,
eta0=self.eta0,
power_t=self.power_t,
shuffle=True,
average=self.average,
random_state=self.random_state,
warm_start=True)
self.estimator.fit(X, y, sample_weight=sample_weight)
self.n_iter_ = self.estimator.n_iter_
else:
self.estimator.max_iter += n_iter
self.estimator.max_iter = min(self.estimator.max_iter,
self.max_iter)
self.estimator._validate_params()
self.estimator._partial_fit(
X,
y,
alpha=self.estimator.alpha,
C=1.0,
loss=self.estimator.loss,
learning_rate=self.estimator.learning_rate,
max_iter=n_iter,
sample_weight=sample_weight,
classes=None,
coef_init=None,
intercept_init=None)
self.n_iter_ += self.estimator.n_iter_
if self.estimator.max_iter >= self.max_iter or self.estimator.max_iter > self.n_iter_:
self.fully_fit_ = True
return self
def configuration_fully_fitted(self):
if self.estimator is None:
return False
elif not hasattr(self, 'fully_fit_'):
return False
else:
return self.fully_fit_
def predict(self, X):
if self.estimator is None:
raise NotImplementedError()
return self.estimator.predict(X)
def predict_proba(self, X):
if self.estimator is None:
raise NotImplementedError()
if self.loss in ['log', 'modified_huber']:
return self.estimator.predict_proba(X)
else:
df = self.estimator.decision_function(X)
return softmax(df)
@staticmethod
def get_properties(dataset_properties=None):
return {
'shortname': 'SGD Classifier',
'name': 'Stochastic Gradient Descent Classifier',
'handles_regression': False,
'handles_classification': True,
'handles_multiclass': True,
'handles_multilabel': False,
'handles_multioutput': False,
'is_deterministic': True,
'input': (DENSE, SPARSE, UNSIGNED_DATA),
'output': (PREDICTIONS, )
}
@staticmethod
def get_hyperparameter_search_space(dataset_properties=None):
cs = ConfigurationSpace()
loss = CategoricalHyperparameter(
'loss',
['hinge', 'log', 'modified_huber', 'squared_hinge', 'perceptron'],
default_value='log',
)
penalty = CategoricalHyperparameter(
'penalty', ['l1', 'l2', 'elasticnet'], default_value='l2')
alpha = UniformFloatHyperparameter(
'alpha', 1e-7, 1e-1, log=True, default_value=0.0001)
l1_ratio = UniformFloatHyperparameter(
'l1_ratio', 1e-9, 1, log=True, default_value=0.15)
fit_intercept = UnParametrizedHyperparameter('fit_intercept', 'True')
tol = UniformFloatHyperparameter(
'tol', 1e-5, 1e-1, log=True, default_value=1e-4)
epsilon = UniformFloatHyperparameter(
'epsilon', 1e-5, 1e-1, default_value=1e-4, log=True)
learning_rate = CategoricalHyperparameter(
'learning_rate', ['optimal', 'invscaling', 'constant'],
default_value='invscaling')
eta0 = UniformFloatHyperparameter(
'eta0', 1e-7, 1e-1, default_value=0.01, log=True)
power_t = UniformFloatHyperparameter(
'power_t', 1e-5, 1, default_value=0.5)
average = CategoricalHyperparameter(
'average', ['False', 'True'], default_value='False')
cs.add_hyperparameters([
loss, penalty, alpha, l1_ratio, fit_intercept, tol, epsilon,
learning_rate, eta0, power_t, average
])
# TODO add passive/aggressive here, although not properly documented?
elasticnet = EqualsCondition(l1_ratio, penalty, 'elasticnet')
epsilon_condition = EqualsCondition(epsilon, loss, 'modified_huber')
power_t_condition = EqualsCondition(power_t, learning_rate,
'invscaling')
# eta0 is only relevant if learning_rate!='optimal' according to code
# https://github.com/scikit-learn/scikit-learn/blob/0.19.X/sklearn/
# linear_model/sgd_fast.pyx#L603
eta0_in_inv_con = InCondition(eta0, learning_rate,
['invscaling', 'constant'])
cs.add_conditions([
elasticnet, epsilon_condition, power_t_condition, eta0_in_inv_con
])
return cs
|
1680674
|
class Solution:
def arrangeCoins(self, n: int) -> int:
return int ((-1 + (1 + 8*n) ** 0.5 ) / 2)
|
1680687
|
import os
import pickle
def save_pkl(instances, pickle_dict, is_training):
if is_pickle_dict_valid(pickle_dict):
os.makedirs(pickle_dict["path"], exist_ok=True)
with open(get_pkl_path(pickle_dict, is_training), "wb") as dataset_file:
pickle.dump(instances, dataset_file)
def load_pkl(pickle_dict, is_training):
try:
with open(get_pkl_path(pickle_dict, is_training), "rb") as dataset_pkl:
return pickle.load(dataset_pkl)
except Exception as e:
return None
def get_pkl_path(pickle_dict, is_training):
return os.path.join(
pickle_dict["path"],
f"{pickle_dict['file_name']}_{'train' if is_training else 'dev'}.pkl",
)
def is_pickle_dict_valid(pickle_dict):
if pickle_dict is None:
return False
file_name = pickle_dict.get("file_name", None)
path = pickle_dict.get("path", None)
return file_name is not None and path is not None
|
1680763
|
from cypherpunkpay.explorers.bitcoin.bitaps_explorer import BitapsExplorer
from cypherpunkpay.explorers.bitcoin.bitaroo_explorer import BitarooExplorer
from cypherpunkpay.explorers.bitcoin.blockstream_explorer import BlockstreamExplorer
from cypherpunkpay.explorers.bitcoin.emzy_explorer import EmzyExplorer
from cypherpunkpay.explorers.bitcoin.mempool_explorer import MempoolExplorer
from cypherpunkpay.explorers.bitcoin.trezor_explorer import TrezorExplorer
from cypherpunkpay.exceptions import UnsupportedNetwork, UnsupportedCoin
class SupportedExplorers(object):
BTC_MAINNET = [
BitapsExplorer,
BlockstreamExplorer,
BitarooExplorer,
EmzyExplorer,
MempoolExplorer,
TrezorExplorer,
]
BTC_TESTNET = [
BitapsExplorer,
BlockstreamExplorer,
MempoolExplorer,
TrezorExplorer,
]
XMR_MAINNET = []
XMR_STAGENET = []
def get(self, coin: str, network: str):
if coin == 'btc':
if network == 'mainnet':
return self.BTC_MAINNET
if network == 'testnet':
return self.BTC_TESTNET
raise UnsupportedNetwork(network)
if coin == 'xmr':
if network == 'mainnet':
return self.XMR_MAINNET
if network == 'stagenet':
return self.XMR_STAGENET
raise UnsupportedNetwork(network)
raise UnsupportedCoin(coin)
|
1680767
|
def ask_for_stop(use_back):
import pydevd
if use_back:
pydevd.settrace(stop_at_frame=sys._getframe().f_back)
else:
pydevd.settrace()
print('Will stop here if use_back==False.')
def outer_method():
ask_for_stop(True)
print('will stop here.')
ask_for_stop(False)
if __name__ == '__main__':
import os
import sys
root_dirname = os.path.dirname(os.path.dirname(__file__))
if root_dirname not in sys.path:
sys.path.append(root_dirname)
outer_method()
print('TEST SUCEEDED!')
|
1680811
|
version_info = (4, 2, 0) # pragma: no cover
__version__ = '.'.join(str(v) for v in version_info) # pragma: no cover
|
1680826
|
import getpass
import logging
import sys
from django.core.management.base import BaseCommand
from django.db import transaction, IntegrityError
from django.urls import reverse
from django.utils.crypto import get_random_string
import requests
from zentral.conf import settings
from zentral.contrib.okta.models import EventHook
logger = logging.getLogger("zentral.contrib.okta.management.commands.setup_okta_event_hook")
class Command(BaseCommand):
help = "Setup Okta event hook"
def add_arguments(self, parser):
pass
def stop_with_err_msg(self, message):
print(message, dev=sys.stderr)
sys.exit(1)
def handle(self, *args, **kwargs):
okta_domain = input("Okta domain: ")
api_token = <PASSWORD>("API token: ")
name = input("Name: ")
event_hook = None
for _ in range(10):
authorization_key = get_random_string(64)
try:
with transaction.atomic():
event_hook = EventHook.objects.create(
okta_domain=okta_domain,
api_token=api_token,
name=name,
authorization_key=authorization_key
)
except IntegrityError:
if EventHook.objects.filter(okta_domain=okta_domain, name=name):
self.stop_with_err_msg("Event hook with the same name for that domain already exists")
else:
break
else:
self.stop_with_err_msg("Could not create event hook")
session = requests.Session()
session.headers.update({"Accept": "application/json",
"Authorization": "SSWS {}".format(event_hook.api_token),
"Content-Type": "application/json"})
event_hook_uri = "{}{}".format(settings["api"]["tls_hostname"], reverse("okta:event_hook"))
request_body = {
"name": event_hook.name,
"events": {
"type": "EVENT_TYPE",
"items": [
"user.session.end",
"user.session.start",
"user.authentication.authenticate",
]
},
"channel": {
"type": "HTTP",
"version": "1.0.0",
"config": {
"uri": event_hook_uri,
"headers": [
{
"key": "X-Zentral-Okta-Event-Hook-ID",
"value": str(event_hook.pk)
}
],
"authScheme": {
"type": "HEADER",
"key": "Authorization",
"value": event_hook.authorization_key
}
}
}
}
response = session.post(
"https://{}//api/v1/eventHooks".format(event_hook.okta_domain),
json=request_body
)
event_hook_d = response.json()
try:
event_hook.okta_id = event_hook_d["id"]
event_hook.save()
print("VERIFY & ACTIVATE")
verify_url = event_hook_d["_links"]["verify"]["href"]
response = session.post(verify_url)
event_hook_d = response.json()
print(event_hook_d["status"] == "ACTIVE")
except Exception:
self.stop_with_err_msg("Could not create and verify Okta event hook.")
|
1680831
|
import torch
import torch.nn as nn
import torch.nn.functional as F
import torch.optim as optim
from torch.utils.data import DataLoader
from torchvision import datasets, transforms
import time
import argparse
class ConvNet(nn.Module):
def __init__(self):
super(ConvNet, self).__init__()
self.cn1 = nn.Conv2d(1, 16, 3, 1)
self.cn2 = nn.Conv2d(16, 32, 3, 1)
self.dp1 = nn.Dropout2d(0.10)
self.dp2 = nn.Dropout2d(0.25)
self.fc1 = nn.Linear(4608, 64) # 4608 is basically 12 X 12 X 32
self.fc2 = nn.Linear(64, 10)
def forward(self, x):
x = self.cn1(x)
x = F.relu(x)
x = self.cn2(x)
x = F.relu(x)
x = F.max_pool2d(x, 2)
x = self.dp1(x)
x = torch.flatten(x, 1)
x = self.fc1(x)
x = F.relu(x)
x = self.dp2(x)
x = self.fc2(x)
op = F.log_softmax(x, dim=1)
return op
def train(args):
torch.manual_seed(0)
device = torch.device("cpu")
train_dataloader = torch.utils.data.DataLoader(
datasets.MNIST('../data', train=True, download=True,
transform=transforms.Compose([
transforms.ToTensor(),
transforms.Normalize((0.1302,), (0.3069,))])),
batch_size=128, shuffle=True)
model = ConvNet()
optimizer = optim.Adadelta(model.parameters(), lr=0.5)
model.train()
for epoch in range(args.epochs):
for b_i, (X, y) in enumerate(train_dataloader):
X, y = X.to(device), y.to(device)
pred_prob = model(X)
loss = F.nll_loss(pred_prob, y) # nll is the negative likelihood loss
optimizer.zero_grad()
loss.backward()
optimizer.step()
if b_i % 10 == 0:
print('epoch: {} [{}/{} ({:.0f}%)]\t training loss: {:.6f}'.format(
epoch, b_i, len(train_dataloader),
100. * b_i / len(train_dataloader), loss.item()))
def main():
parser = argparse.ArgumentParser()
parser.add_argument('--epochs', default=1, type=int)
args = parser.parse_args()
start = time.time()
train(args)
print(f"Finished training in {time.time()-start} secs")
if __name__ == '__main__':
main()
|
1680838
|
import torch
import torch.nn as nn
from torch.autograd import Variable
from correlation_package.modules.corr import Correlation, Correlation1d
from correlation_package.functions.corr import correlation, correlation1d
from torch.autograd import gradcheck
import numpy as np
def test_correlation():
# model = correlation(1, 1, 1, 1, 1, 1)
# A = Variable(torch.randn(1,1,3,3))
# A_ = A.cuda()
# B = Variable(torch.randn(1,1,3,3))
# B_ = B.cuda()
#
# #import pdb; pdb.set_trace()
# #model = correlation1d(3, 1, 20, 1, 1, 1)
# y = model(A_, B_)
# print(y.size())
#
# print(y)
# return
A = Variable(torch.randn(2,3,100,100), requires_grad=True)
A_ = A.cuda()
B = Variable(torch.randn(2,3,100,100), requires_grad=True)
B_ = B.cuda()
model = correlation(3, 3, 20, 1, 2, 1)
y = model(A_, B_)
print(y.size())
print('Functional interface test passed')
z = torch.mean(y)
z.backward()
print(A.grad.size())
print(B.grad.size())
if A.grad is not None and B.grad is not None:
print('Backward pass test passed')
A = Variable(torch.randn(2,3,100,100), requires_grad=True)
A_ = A.cuda()
B = Variable(torch.randn(2,3,100,100), requires_grad=True)
B_ = B.cuda()
y = Correlation(3, 3, 20, 1, 2, 1)(A_, B_)
print(y.size())
print('Module interface test passed')
z = torch.mean(y)
z.backward()
print(A.grad.size())
print(B.grad.size())
if A.grad is not None and B.grad is not None:
print('Backward pass test passed')
def test_correlation_0():
#model = correlation(0, 1, 0, 1, 1, 1)
A = torch.Tensor([[1,2],[3,4]])
B = torch.Tensor([[5,6],[7,8]])
A = A.view((1,1,2,2))
B = B.view((1,1,2,2))
A = Variable(A)
B = Variable(B)
A_ = A.cuda()
B_ = B.cuda()
#y = model(A_, B_)
#print(y) # should be 1x1x2x2 [[5,12],[21,32]]
model2 = correlation(1, 1, 1, 1, 1, 1)
y2 = model2(A_, B_)
print(y2) # should be 1x9x2x2
def test_correlation1d_0():
#model = correlation1d(0, 1, 0, 1, 1, 1)
A = torch.Tensor([[1,2],[3,4]])
B = torch.Tensor([[5,6],[7,8]])
A = A.view((1,1,2,2))
B = B.view((1,1,2,2))
A = Variable(A)
B = Variable(B)
A_ = A.cuda()
B_ = B.cuda()
#y = model(A_, B_)
#print(y) # should be 1x1x2x2 [[5,12],[21,32]]
model2 = correlation1d(1, 1, 1, 1, 1, 1)
y2 = model2(A_, B_)
print(y2) # should be 1x3x2x2
return
def test_correlation1d():
A = Variable(torch.randn(2,3,100,100), requires_grad=True)
A_ = A.cuda()
B = Variable(torch.randn(2,3,100,100), requires_grad=True)
B_ = B.cuda()
#import pdb; pdb.set_trace()
model = correlation1d(20, 1, 20, 1, 1, 1)
y = model(A_, B_)
print(y.size())
print('Functional interface test passed')
z = torch.mean(y)
z.backward()
print(A.grad.size())
print(B.grad.size())
if A.grad is not None and B.grad is not None:
print('Backward pass test passed')
A = Variable(torch.randn(2,3,100,100), requires_grad=True)
A_ = A.cuda()
B = Variable(torch.randn(2,3,100,100), requires_grad=True)
B_ = B.cuda()
y = Correlation1d(20, 1, 20, 1, 1, 1)(A_, B_)
print(y.size())
print('Module interface test passed')
z = torch.mean(y)
z.backward()
print(A.grad.size())
print(B.grad.size())
if A.grad is not None and B.grad is not None:
print('Backward pass test passed')
if __name__=='__main__':
#test_correlation()
#test_correlation1d()
#test_correlation_0()
test_correlation1d_0()
|
1680868
|
from yozuch import logger
from yozuch.generators.template import TemplateEntry, TemplateGenerator
from yozuch.utils import format_url_from_object
class PostItemCollectionGenerator(TemplateGenerator):
def __init__(self, collection_name, item_name, url_template, name, template):
super().__init__(url_template, name, template)
self._collection_name = collection_name
self._item_name = item_name
def generate(self, context):
if 'posts' not in context.site:
return
items = context.site.get(self._collection_name, [])
logger.info('Found {} {}'.format(len(items), self._collection_name))
for item in items:
page_id = '{}/{}'.format(self.name, item.slug)
item.url = format_url_from_object(self.url_template, item)
yield TemplateEntry(item.url, self.template, page_id, template_vars={self._item_name: item})
|
1680892
|
from a10sdk.common.A10BaseClass import A10BaseClass
class FailMsgCfg(A10BaseClass):
"""This class does not support CRUD Operations please use parent.
:param fail_font_custom: {"description": "Specify custom font", "format": "string-rlx", "minLength": 1, "maxLength": 63, "not": "fail-face", "type": "string"}
:param fail_color: {"default": 0, "type": "number", "description": "Specify font color", "format": "flag"}
:param fail_size: {"description": "Specify font size", "minimum": 1, "type": "number", "maximum": 7, "format": "number"}
:param fail_msg: {"default": 0, "type": "number", "description": "Configure logon failure message in default logon fail page", "format": "flag"}
:param fail_text: {"minLength": 1, "maxLength": 63, "type": "string", "description": "Specify logon failure message (Default: Login Failed!!)", "format": "string-rlx"}
:param fail_color_value: {"description": "Specify 6-digit HEX color value", "format": "string", "minLength": 6, "maxLength": 6, "not": "fail-color-name", "type": "string"}
:param fail_font: {"default": 0, "type": "number", "description": "Sepcify font", "format": "flag"}
:param fail_color_name: {"not": "fail-color-value", "enum": ["aqua", "black", "blue", "fuchsia", "gray", "green", "lime", "maroon", "navy", "olive", "orange", "purple", "red", "silver", "teal", "white", "yellow"], "type": "string", "description": "'aqua': aqua; 'black': black; 'blue': blue; 'fuchsia': fuchsia; 'gray': gray; 'green': green; 'lime': lime; 'maroon': maroon; 'navy': navy; 'olive': olive; 'orange': orange; 'purple': purple; 'red': red; 'silver': silver; 'teal': teal; 'white': white; 'yellow': yellow; ", "format": "enum"}
:param fail_face: {"not": "fail-font-custom", "enum": ["Arial", "Courier_New", "Georgia", "Times_New_Roman", "Verdana"], "type": "string", "description": "'Arial': Arial; 'Courier_New': Courier New; 'Georgia': Georgia; 'Times_New_Roman': Times New Roman; 'Verdana': Verdana; ", "format": "enum"}
:param DeviceProxy: The device proxy for REST operations and session handling. Refer to `common/device_proxy.py`
"""
def __init__(self, **kwargs):
self.ERROR_MSG = ""
self.b_key = "<KEY>"
self.DeviceProxy = ""
self.fail_font_custom = ""
self.fail_color = ""
self.fail_size = ""
self.fail_msg = ""
self.fail_text = ""
self.fail_color_value = ""
self.fail_font = ""
self.fail_color_name = ""
self.fail_face = ""
for keys, value in kwargs.items():
setattr(self,keys, value)
class TitleCfg(A10BaseClass):
"""This class does not support CRUD Operations please use parent.
:param title: {"default": 0, "type": "number", "description": "Configure title in default logon fail page", "format": "flag"}
:param title_color: {"default": 0, "type": "number", "description": "Specify font color", "format": "flag"}
:param title_color_name: {"not": "title-color-value", "enum": ["aqua", "black", "blue", "fuchsia", "gray", "green", "lime", "maroon", "navy", "olive", "orange", "purple", "red", "silver", "teal", "white", "yellow"], "type": "string", "description": "'aqua': aqua; 'black': black; 'blue': blue; 'fuchsia': fuchsia; 'gray': gray; 'green': green; 'lime': lime; 'maroon': maroon; 'navy': navy; 'olive': olive; 'orange': orange; 'purple': purple; 'red': red; 'silver': silver; 'teal': teal; 'white': white; 'yellow': yellow; ", "format": "enum"}
:param title_font_custom: {"description": "Specify custom font", "format": "string-rlx", "minLength": 1, "maxLength": 63, "not": "title-face", "type": "string"}
:param title_face: {"not": "title-font-custom", "enum": ["Arial", "Courier_New", "Georgia", "Times_New_Roman", "Verdana"], "type": "string", "description": "'Arial': Arial; 'Courier_New': Courier New; 'Georgia': Georgia; 'Times_New_Roman': Times New Roman; 'Verdana': Verdana; ", "format": "enum"}
:param title_color_value: {"description": "Specify 6-digit HEX color value", "format": "string", "minLength": 6, "maxLength": 6, "not": "title-color-name", "type": "string"}
:param title_size: {"description": "Specify font size", "minimum": 1, "type": "number", "maximum": 7, "format": "number"}
:param title_text: {"minLength": 1, "maxLength": 63, "type": "string", "description": "Specify title (Default: Try Too Many Times)", "format": "string-rlx"}
:param title_font: {"default": 0, "type": "number", "description": "Sepcify font", "format": "flag"}
:param DeviceProxy: The device proxy for REST operations and session handling. Refer to `common/device_proxy.py`
"""
def __init__(self, **kwargs):
self.ERROR_MSG = ""
self.b_key = "title-cfg"
self.DeviceProxy = ""
self.title = ""
self.title_color = ""
self.title_color_name = ""
self.title_font_custom = ""
self.title_face = ""
self.title_color_value = ""
self.title_size = ""
self.title_text = ""
self.title_font = ""
for keys, value in kwargs.items():
setattr(self,keys, value)
class Background(A10BaseClass):
"""This class does not support CRUD Operations please use parent.
:param bgfile: {"description": "Specify background image filename", "format": "string-rlx", "minLength": 1, "maxLength": 63, "not": "bgcolor", "type": "string"}
:param bgstyle: {"enum": ["tile", "stretch", "fit"], "type": "string", "description": "'tile': Tile; 'stretch': Stretch; 'fit': Fit; ", "format": "enum"}
:param bgcolor_value: {"description": "Specify 6-digit HEX color value", "format": "string", "minLength": 6, "maxLength": 6, "not": "bgcolor-name", "type": "string"}
:param bgcolor_name: {"not": "bgcolor-value", "enum": ["aqua", "black", "blue", "fuchsia", "gray", "green", "lime", "maroon", "navy", "olive", "orange", "purple", "red", "silver", "teal", "white", "yellow"], "type": "string", "description": "'aqua': aqua; 'black': black; 'blue': blue; 'fuchsia': fuchsia; 'gray': gray; 'green': green; 'lime': lime; 'maroon': maroon; 'navy': navy; 'olive': olive; 'orange': orange; 'purple': purple; 'red': red; 'silver': silver; 'teal': teal; 'white': white; 'yellow': yellow; ", "format": "enum"}
:param bgcolor: {"default": 0, "not": "bgfile", "type": "number", "description": "Specify background color", "format": "flag"}
:param DeviceProxy: The device proxy for REST operations and session handling. Refer to `common/device_proxy.py`
"""
def __init__(self, **kwargs):
self.ERROR_MSG = ""
self.b_key = "background"
self.DeviceProxy = ""
self.bgfile = ""
self.bgstyle = ""
self.bgcolor_value = ""
self.bgcolor_name = ""
self.bgcolor = ""
for keys, value in kwargs.items():
setattr(self,keys, value)
class LogonFail(A10BaseClass):
"""Class Description::
Logon fail page configuration.
Class logon-fail supports CRUD Operations and inherits from `common/A10BaseClass`.
This class is the `"PARENT"` class for this module.`
:param uuid: {"description": "uuid of the object", "format": "string", "minLength": 1, "modify-not-allowed": 1, "optional": true, "maxLength": 64, "type": "string"}
:param DeviceProxy: The device proxy for REST operations and session handling. Refer to `common/device_proxy.py`
URL for this object::
`https://<Hostname|Ip address>//axapi/v3/aam/authentication/portal/{name}/logon-fail`.
"""
def __init__(self, **kwargs):
self.ERROR_MSG = ""
self.required=[]
self.b_key = "logon-fail"
self.a10_url="/axapi/v3/aam/authentication/portal/{name}/logon-fail"
self.DeviceProxy = ""
self.fail_msg_cfg = {}
self.title_cfg = {}
self.background = {}
self.uuid = ""
for keys, value in kwargs.items():
setattr(self,keys, value)
|
1680900
|
import datetime
import logging
import re
import icalendar
import recurring_ical_events
_LOGGER = logging.getLogger(__name__)
class ICS:
def __init__(self, offset=None, regex=None, split_at=None):
self._offset = offset
self._regex = None
if regex is not None:
self._regex = re.compile(regex)
self._split_at = split_at
def convert(self, ics_data):
# parse ics file
try:
calendar = icalendar.Calendar.from_ical(ics_data)
except Exception as err:
_LOGGER.error(f"Parsing ics data failed:{str(err)}")
_LOGGER.debug(ics_data)
return []
# calculate start- and end-date for recurring events
start_date = datetime.datetime.now().replace(
hour=0, minute=0, second=0, microsecond=0
)
if self._offset is not None:
start_date -= datetime.timedelta(days=self._offset)
end_date = start_date.replace(year=start_date.year + 1)
events = recurring_ical_events.of(calendar).between(start_date, end_date)
entries = []
for e in events:
if e.name == "VEVENT":
# calculate date
dtstart = None
if type(e.get("dtstart").dt) == datetime.date:
dtstart = e.get("dtstart").dt
elif type(e.get("dtstart").dt) == datetime.datetime:
dtstart = e.get("dtstart").dt.date()
if self._offset is not None:
dtstart += datetime.timedelta(days=self._offset)
# calculate waste type
summary = str(e.get("summary"))
if self._regex is not None:
match = self._regex.match(summary)
if match:
summary = match.group(1)
if self._split_at is not None:
summary = re.split(self._split_at, summary)
for t in summary:
entries.append((dtstart, t.strip().title()))
else:
entries.append((dtstart, summary))
return entries
|
1680928
|
from core.advbase import *
class Yoshitsune(Adv):
comment = "no counter on s1/dodge"
def prerun(self):
self.allow_dodge = False
class Yoshitsune_COUNTER(Yoshitsune):
comment = "always counter on s1/dodge"
def prerun(self):
super().prerun()
self.conf.s1.attr = self.conf.s1.attr_counter
self.allow_dodge = True
variants = {None: Yoshitsune, "COUNTER": Yoshitsune_COUNTER}
|
1680950
|
from .core import StrategyList
class FallbackStrategies(StrategyList):
"""
The StrategyList containing fallback strategies.
"""
NAME = "fallback"
@staticmethod
def strategy_override(config, path, base, nxt):
"""use nxt, and ignore base."""
return nxt
@staticmethod
def strategy_use_existing(config, path, base, nxt):
"""use base, and ignore next."""
return base
|
1680960
|
import time
from tools.datahelp import flatten_into_set
from tools.misc import list_to_hashed_dict
class Page(object):
data = None
def __init__(self):
self.data = []
def add_row(self, row):
self.data.append(row)
class PageFetcher(object):
"""
Requests pages, handles their receipt,
and provides paged data for testing.
The first page is automatically retrieved, so an initial
call to request_one is actually getting the *second* page!
"""
pages = None
error = None
future = None
requested_pages = None
retrieved_pages = None
retrieved_empty_pages = None
def __init__(self, future):
self.pages = []
# the first page is automagically returned (eventually)
# so we'll count this as a request, but the retrieved count
# won't be incremented until it actually arrives
self.requested_pages = 1
self.retrieved_pages = 0
self.retrieved_empty_pages = 0
self.future = future
self.future.add_callbacks(
callback=self.handle_page,
errback=self.handle_error
)
# wait for the first page to arrive, otherwise we may call
# future.has_more_pages too early, since it should only be
# called after the first page is returned
self.wait(seconds=30)
def handle_page(self, rows):
# occasionally get a final blank page that is useless
if rows == []:
self.retrieved_empty_pages += 1
return
page = Page()
self.pages.append(page)
for row in rows:
page.add_row(row)
self.retrieved_pages += 1
def handle_error(self, exc):
self.error = exc
raise exc
def request_one(self, timeout=None):
"""
Requests the next page if there is one.
If the future is exhausted, this is a no-op.
@param timeout Time, in seconds, to wait for all pages.
"""
if self.future.has_more_pages:
self.future.start_fetching_next_page()
self.requested_pages += 1
self.wait(seconds=timeout)
return self
def request_all(self, timeout=None):
"""
Requests any remaining pages.
If the future is exhausted, this is a no-op.
@param timeout Time, in seconds, to wait for all pages.
"""
while self.future.has_more_pages:
self.future.start_fetching_next_page()
self.requested_pages += 1
self.wait(seconds=timeout)
return self
def wait(self, seconds=None):
"""
Blocks until all *requested* pages have been returned.
Requests are made by calling request_one and/or request_all.
Raises RuntimeError if seconds is exceeded.
"""
seconds = 5 if seconds is None else seconds
expiry = time.time() + seconds
while time.time() < expiry:
if self.requested_pages == (self.retrieved_pages + self.retrieved_empty_pages):
return self
# small wait so we don't need excess cpu to keep checking
time.sleep(0.1)
raise RuntimeError(
"Requested pages were not delivered before timeout. " +
"Requested: {}; retrieved: {}; empty retrieved: {}".format(self.requested_pages, self.retrieved_pages, self.retrieved_empty_pages))
def pagecount(self):
"""
Returns count of *retrieved* pages which were not empty.
Pages are retrieved by requesting them with request_one and/or request_all.
"""
return len(self.pages)
def num_results(self, page_num):
"""
Returns the number of results found at page_num
"""
return len(self.pages[page_num - 1].data)
def num_results_all(self):
return [len(page.data) for page in self.pages]
def page_data(self, page_num):
"""
Returns retreived data found at pagenum.
The page should have already been requested with request_one and/or request_all.
"""
return self.pages[page_num - 1].data
def all_data(self):
"""
Returns all retrieved data flattened into a single list (instead of separated into Page objects).
The page(s) should have already been requested with request_one and/or request_all.
"""
all_pages_combined = []
for page in self.pages:
all_pages_combined.extend(page.data[:])
return all_pages_combined
@property # make property to match python driver api
def has_more_pages(self):
"""
Returns bool indicating if there are any pages not retrieved.
"""
return self.future.has_more_pages
class PageAssertionMixin(object):
"""Can be added to subclasses of unittest.Tester"""
def assertEqualIgnoreOrder(self, actual, expected):
hashed_expected = list_to_hashed_dict(expected)
hashed_actual = list_to_hashed_dict(actual)
for key, expected in hashed_expected.items():
assert key in hashed_actual, "expected %s not in actual" % str(expected)
actual = hashed_actual[key]
assert actual == expected, "actual %s not same as expected %s" % (str(actual), str(expected))
for key, actual in hashed_actual.items():
assert key in hashed_expected, "actual %s not in expected" % str(actual)
expected = hashed_expected[key]
assert expected == actual, "expected %s not same as actual %s" % (str(expected), str(actual))
assert hashed_expected == hashed_actual
def assertIsSubsetOf(self, subset, superset):
assert flatten_into_set(subset) <= flatten_into_set(superset)
|
1680970
|
import datetime
import importlib
import sys
import tempfile
import uuid
from pathlib import Path
from logexp.experiment import Experiment
from logexp.metadata.git import get_git_info
from logexp.logstore import LogStore
from logexp.params import Params
from logexp.report import Report
from logexp.metadata.platform import get_platform_info
from logexp.metadata.status import Status
from logexp.metadata.runinfo import RunInfo
from logexp.version import VERSION
class TestLogStore:
def setup(self):
sys.path.append("examples/")
importlib.import_module("hello")
self.experiment_name = "my_experiment"
self.worker_name = "my_worker"
self.experiment = Experiment.get_experiment(self.experiment_name)
def test_create_and_get_experiment(self):
with tempfile.TemporaryDirectory() as tempdir:
rootdir = Path(tempdir)
store = LogStore(rootdir)
experiment_id = store.create_experiment(self.experiment)
experiment = store.get_experiment(experiment_id)
assert experiment.name == self.experiment_name
def test_save_and_load_run(self):
with tempfile.TemporaryDirectory() as tempdir:
rootdir = Path(tempdir)
store = LogStore(rootdir)
experiment_id = store.create_experiment(self.experiment)
run_id = store.create_run(experiment_id, self.worker_name)
run_info = RunInfo(
version=VERSION,
uuid=run_id,
name="test run",
module="test_module",
execution_path=Path("test/path"),
experiment_id=experiment_id,
experiment_name=self.experiment_name,
worker_name=self.worker_name,
status=Status.FINISHED,
params=Params({"test": "params"}),
report=Report({"test": "report"}),
storage=store.get_storage(experiment_id, run_id),
platform=get_platform_info(),
git=get_git_info(),
note="test note",
stdout="test stdout",
stderr="test stderr",
start_time=datetime.datetime.now(),
end_time=datetime.datetime.now(),
)
store.save_run(run_info)
run_info_ = store.load_run(run_id)
assert run_info_.uuid == run_id
assert run_info_.stdout == "test stdout"
def test_get_runs(self):
with tempfile.TemporaryDirectory() as tempdir:
rootdir = Path(tempdir)
store = LogStore(rootdir)
experiment_id = store.create_experiment(self.experiment)
run_id = store.create_run(experiment_id, self.worker_name)
run_info = RunInfo(
version=VERSION,
uuid=run_id,
name="test run",
module="test_module",
execution_path=Path("test/path"),
experiment_id=experiment_id,
experiment_name=self.experiment_name,
worker_name=self.worker_name,
status=Status.FINISHED,
params=Params({"test": "params"}),
report=Report({"test": "report"}),
storage=store.get_storage(experiment_id, run_id),
platform=get_platform_info(),
git=get_git_info(),
note="test note",
stdout="test stdout",
stderr="test stderr",
start_time=datetime.datetime.now(),
end_time=datetime.datetime.now(),
)
store.save_run(run_info)
runinfos = store.get_runs(
experiment_id=experiment_id,
worker_name=self.worker_name
)
assert runinfos[0].uuid == run_id
def test_delete_run(self):
with tempfile.TemporaryDirectory() as tempdir:
rootdir = Path(tempdir)
store = LogStore(rootdir)
experiment_id = store.create_experiment(self.experiment)
run_id = store.create_run(experiment_id, self.worker_name)
run_info = RunInfo(
version=VERSION,
uuid=run_id,
name="test run",
module="test_module",
execution_path=Path("test/path"),
experiment_id=experiment_id,
experiment_name=self.experiment_name,
worker_name=self.worker_name,
status=Status.FINISHED,
params=Params({"test": "params"}),
report=Report({"test": "report"}),
storage=store.get_storage(experiment_id, run_id),
platform=get_platform_info(),
git=get_git_info(),
note="test note",
stdout="test stdout",
stderr="test stderr",
start_time=datetime.datetime.now(),
end_time=datetime.datetime.now(),
)
store.save_run(run_info)
assert (rootdir / str(experiment_id) / self.worker_name / run_id).exists()
runinfos = store.delete_run(run_id)
assert not (rootdir / str(experiment_id) / self.worker_name / run_id).exists()
|
1680976
|
import turicreate as tc
#use sframe containing all images
data = tc.SFrame('Nolmyra2.sframe')
train_set, test_set = data.random_split(0.8)
train_set.save("Train_Data.sframe")
test_set.save("Test_Data.sframe")
|
1680987
|
import torch
import numpy as np
import os
import json
default_device = torch.device(f"cuda:0" if torch.cuda.is_available() else "cpu")
def test(model, iter, repeats=5, steps=50, device=default_device):
res_path = os.path.join(model.model_dir, 'test_results.json')
model.eval()
accs = []
for _ in range(repeats):
eq = 0
total = 0
for data in iter:
data = data.to(device)
y = data.y
data = model(data, steps)
correct = data.y_pred.argmax(dim=1).eq(y.view(-1)).sum()
eq += correct.cpu().detach().numpy()
total += float(y.shape[0])
accs.append(eq / float(total))
acc = np.mean(accs)
std = np.std(accs)
print(f'Test Score: {acc:.4f} (+-{std:.4f})')
with open(res_path, 'w') as f:
json.dump({'score': float(acc), 'std': float(std)}, f, indent=4)
return acc, std
|
1681025
|
from demos import bisection_iter, analyze_func, generate_emails
# Add domains to list below for additional email extensions
list_of_domains = ['yaexample.com','goexample.com','example.com']
# Generate emails
emails = generate_emails(10,list_of_domains,1000000)
# Test email to add to list of emails, followed by append to list
email = '<EMAIL>'
emails.append(email)
# Sort list of generated emails
sorted_emails = sorted(emails)
# Run bisection search to find test email in sorted list of emails
index, found = bisection_iter(email, sorted_emails)
# Print result from function
print(found)
# Print index returned by function used on the list of sorted emails
if index: print(f"element at index: {index} is {sorted_emails[index]}")
# Run analysis of functions
analyze_func(bisection_iter, email, sorted_emails)
analyze_func(generate_emails, 10, list_of_domains, 1000000)
|
1681034
|
from mapping_common import *
openflow_tables = {
"dmac": OFTable(
match_fields = {
"ethernet_dstAddr" : OFMatchField(field="OFPXMT_OFB_ETH_DST")
},
id = 0
)
}
|
1681064
|
import asyncio
import pytest
import starkware.starknet.testing.objects
from starkware.starknet.testing.starknet import Starknet
from starkware.starkware_utils.error_handling import StarkException
from tests.utils import Signer, str_to_felt, to_uint, uint
FALSE, TRUE = 0, 1
signer = Signer(123456789987654321)
NONEXISTENT_TOKEN = to_uint(999)
# random token IDs
TOKENS = [to_uint(5042), to_uint(793)]
# test token
TOKEN = TOKENS[0]
INITIAL_PRICE = 1000
DECAY_CONSTANT = 1
SCALE_FACTOR = 10
@pytest.fixture(scope="module")
def event_loop():
return asyncio.new_event_loop()
@pytest.fixture(scope="module")
async def contract_factory():
# Deploy the contracts
starknet = await Starknet.empty()
account1 = await starknet.deploy(
"openzeppelin/account/Account.cairo",
constructor_calldata=[signer.public_key],
)
contract = await starknet.deploy(
"contracts/discreteGDA.cairo",
constructor_calldata=[
str_to_felt("Non Fungible Token"), # name
str_to_felt("NFT"), # ticker
account1.contract_address, # owner
INITIAL_PRICE,
SCALE_FACTOR,
DECAY_CONSTANT,
],
)
account2 = await starknet.deploy(
"openzeppelin/account/Account.cairo",
constructor_calldata=[signer.public_key],
)
# ERC20 type accepted as payment
erc20 = await starknet.deploy(
"openzeppelin/token/erc20/ERC20_Mintable.cairo",
constructor_calldata=[
str_to_felt("Mintable Token"),
str_to_felt("MTKN"),
18,
*to_uint(INITIAL_PRICE + 1002),
account2.contract_address,
account2.contract_address,
],
)
# Approve the tokens for the auction contract
await signer.send_transaction(
account=account2,
to=erc20.contract_address,
selector_name="approve",
calldata=[contract.contract_address, *to_uint(INITIAL_PRICE)],
)
return starknet, contract, account1, account2, erc20
@pytest.mark.asyncio
async def test_initial_price(contract_factory):
"""Initial price should be price scale"""
starknet, contract, account1, account2, erc20 = contract_factory
observed = await contract.purchase_price(1).call()
assert assertApproxEqual(INITIAL_PRICE, observed.result[0][0], 1)
@pytest.mark.asyncio
async def test_insufficient_payment(contract_factory):
starknet, contract, account1, account2, erc20 = contract_factory
observed = await contract.purchase_price(1).call()
with pytest.raises(StarkException):
await signer.send_transaction(
account=account2,
to=contract.contract_address,
selector_name="purchaseTokens",
calldata=[
1,
account2.contract_address,
*to_uint(observed.result[0][0] - 1),
],
)
@pytest.mark.asyncio
async def test_mint_correctly(contract_factory):
starknet, contract, account1, account2, erc20 = contract_factory
# Checks token has no owner
with pytest.raises(StarkException):
await contract.ownerOf(to_uint(0)).call()
price = await contract.purchase_price(1).call()
await signer.send_transaction(
account=account2,
to=contract.contract_address,
selector_name="purchaseTokens",
calldata=[
1,
account2.contract_address,
*to_uint(1001),
],
)
# Checks token has new owner
new_owner = await contract.ownerOf(to_uint(0)).call()
assert new_owner.result == (account2.contract_address,)
# @pytest.mark.asyncio
# async def test_refund(contract_factory):
# starknet, contract, account1, account2, erc20 = contract_factory
# price = await contract.purchase_price(1).call()
# await signer.send_transaction(
# account=account2,
# to=contract.contract_address,
# selector_name="purchaseTokens",
# calldata=[
# 1,
# account2.contract_address,
# *to_uint(2002),
# ],
# )
# observed = await erc20.balanceOf(account2.contract_address).call()
# assert observed.result == price.result
def assertApproxEqual(expected, actual, tolerance):
print(expected, actual, tolerance)
leftBound = (expected * (1000 - tolerance)) / 1000
rightBound = (expected * (1000 + tolerance)) / 1000
return leftBound <= actual and actual <= rightBound
|
1681091
|
class Shield:
def __init__(self):
self.s7 = 0
self.s6 = 0
self.s5 = 0
self.s4 = 0
self.s3 = 0
self.s2 = 0
self.s1 = 0
self.s0 = 0
def tick(self, inputs):
depth7 = inputs[0]
depth6 = inputs[1]
depth5 = inputs[2]
depth4 = inputs[3]
depth3 = inputs[4]
depth2 = inputs[5]
depth1 = inputs[6]
k2 = inputs[7]
k1 = inputs[8]
oxygen_low = inputs[9]
oxygen_full = inputs[10]
diver_found = inputs[11]
action4_1 = inputs[12]
action3_1 = inputs[13]
action2_1 = inputs[14]
action1_1 = inputs[15]
s7 = self.s7
s6 = self.s6
s5 = self.s5
s4 = self.s4
s3 = self.s3
s2 = self.s2
s1 = self.s1
s0 = self.s0
tmp13 = (1 - (1 if action1_1 else 0))
tmp12 = (1 if action4_1 else tmp13)
tmp15 = (1 if action2_1 else 0)
tmp14 = (tmp15 if oxygen_low else tmp12)
tmp11 = (tmp12 if oxygen_full else tmp14)
tmp10 = (tmp11 if depth7 else tmp12)
tmp9 = (tmp10 if depth6 else tmp12)
tmp19 = (tmp11 if k2 else tmp12)
tmp18 = (tmp19 if depth7 else tmp12)
tmp17 = (tmp18 if depth6 else tmp12)
tmp16 = (tmp9 if depth5 else tmp17)
tmp8 = (tmp9 if depth4 else tmp16)
tmp29 = (1 if action1_1 else 0)
tmp28 = (1 - (tmp29 if action2_1 else 0))
tmp27 = (1 if action4_1 else tmp28)
tmp26 = (tmp12 if oxygen_low else tmp27)
tmp25 = (tmp12 if oxygen_full else tmp26)
tmp24 = (tmp12 if diver_found else tmp25)
tmp23 = (tmp12 if depth7 else tmp24)
tmp22 = (tmp12 if depth6 else tmp23)
tmp21 = (tmp9 if depth5 else tmp22)
tmp20 = (tmp9 if depth4 else tmp21)
tmp7 = (tmp8 if depth3 else tmp20)
tmp32 = (tmp9 if depth5 else tmp12)
tmp31 = (tmp9 if depth4 else tmp32)
tmp30 = (tmp31 if depth3 else tmp20)
tmp6 = (tmp7 if depth2 else tmp30)
tmp39 = (tmp19 if k1 else tmp12)
tmp38 = (tmp39 if depth7 else tmp12)
tmp37 = (tmp38 if depth6 else tmp12)
tmp36 = (tmp9 if depth5 else tmp37)
tmp35 = (tmp9 if depth4 else tmp36)
tmp34 = (tmp35 if depth3 else tmp20)
tmp45 = (tmp11 if k1 else tmp19)
tmp44 = (tmp45 if depth7 else tmp12)
tmp43 = (tmp44 if depth6 else tmp12)
tmp42 = (tmp9 if depth5 else tmp43)
tmp41 = (tmp42 if depth4 else tmp21)
tmp40 = (tmp20 if depth3 else tmp41)
tmp33 = (tmp34 if depth2 else tmp40)
tmp5 = (tmp6 if depth1 else tmp33)
tmp53 = (tmp12 if oxygen_full else tmp15)
tmp52 = (tmp53 if depth7 else tmp12)
tmp51 = (tmp52 if depth6 else tmp12)
tmp58 = (tmp53 if k2 else tmp12)
tmp57 = (tmp53 if k1 else tmp58)
tmp56 = (tmp57 if depth7 else tmp12)
tmp55 = (tmp56 if depth6 else tmp12)
tmp54 = (tmp51 if depth5 else tmp55)
tmp50 = (tmp51 if depth4 else tmp54)
tmp60 = (tmp51 if depth5 else tmp12)
tmp59 = (tmp51 if depth4 else tmp60)
tmp49 = (tmp50 if depth3 else tmp59)
tmp66 = (tmp58 if k1 else tmp12)
tmp65 = (tmp66 if depth7 else tmp12)
tmp64 = (tmp65 if depth6 else tmp12)
tmp63 = (tmp51 if depth5 else tmp64)
tmp62 = (tmp51 if depth4 else tmp63)
tmp61 = (tmp62 if depth3 else tmp59)
tmp48 = (tmp49 if depth2 else tmp61)
tmp72 = (tmp58 if depth7 else tmp12)
tmp71 = (tmp72 if depth6 else tmp12)
tmp70 = (tmp51 if depth5 else tmp71)
tmp69 = (tmp51 if depth4 else tmp70)
tmp68 = (tmp69 if depth3 else tmp59)
tmp67 = (tmp68 if depth2 else tmp59)
tmp47 = (tmp48 if depth1 else tmp67)
tmp75 = (tmp51 if depth3 else tmp59)
tmp74 = (tmp75 if depth2 else tmp68)
tmp73 = (tmp74 if depth1 else tmp48)
tmp46 = (tmp47 if s0 else tmp73)
tmp4 = (tmp5 if s1 else tmp46)
tmp82 = (tmp51 if depth3 else tmp62)
tmp81 = (tmp82 if depth2 else tmp49)
tmp80 = (tmp81 if depth1 else tmp74)
tmp85 = (tmp51 if depth3 else tmp69)
tmp84 = (tmp85 if depth2 else tmp75)
tmp83 = (tmp84 if depth1 else tmp81)
tmp79 = (tmp80 if s0 else tmp83)
tmp89 = (tmp51 if depth3 else tmp50)
tmp88 = (tmp89 if depth2 else tmp82)
tmp87 = (tmp88 if depth1 else tmp84)
tmp91 = (tmp51 if depth2 else tmp85)
tmp90 = (tmp91 if depth1 else tmp88)
tmp86 = (tmp87 if s0 else tmp90)
tmp78 = (tmp79 if s1 else tmp86)
tmp99 = (tmp52 if depth6 else tmp65)
tmp98 = (tmp99 if depth5 else tmp51)
tmp97 = (tmp98 if depth4 else tmp51)
tmp96 = (tmp97 if depth3 else tmp51)
tmp95 = (tmp96 if depth2 else tmp89)
tmp94 = (tmp95 if depth1 else tmp91)
tmp105 = (tmp52 if depth6 else tmp72)
tmp104 = (tmp105 if depth5 else tmp51)
tmp103 = (tmp104 if depth4 else tmp51)
tmp102 = (tmp103 if depth3 else tmp51)
tmp101 = (tmp102 if depth2 else tmp51)
tmp100 = (tmp101 if depth1 else tmp95)
tmp93 = (tmp94 if s0 else tmp100)
tmp112 = (tmp52 if depth6 else tmp56)
tmp111 = (tmp112 if depth5 else tmp51)
tmp110 = (tmp111 if depth4 else tmp51)
tmp109 = (tmp110 if depth3 else tmp51)
tmp108 = (tmp109 if depth2 else tmp96)
tmp107 = (tmp108 if depth1 else tmp101)
tmp117 = (tmp52 if depth5 else tmp51)
tmp116 = (tmp117 if depth4 else tmp51)
tmp115 = (tmp116 if depth3 else tmp51)
tmp114 = (tmp115 if depth2 else tmp102)
tmp113 = (tmp114 if depth1 else tmp108)
tmp106 = (tmp107 if s0 else tmp113)
tmp92 = (tmp93 if s1 else tmp106)
tmp77 = (tmp78 if s2 else tmp92)
tmp123 = (tmp116 if depth3 else tmp97)
tmp122 = (tmp123 if depth2 else tmp109)
tmp121 = (tmp122 if depth1 else tmp114)
tmp126 = (tmp116 if depth3 else tmp103)
tmp125 = (tmp126 if depth2 else tmp115)
tmp124 = (tmp125 if depth1 else tmp122)
tmp120 = (tmp121 if s0 else tmp124)
tmp130 = (tmp116 if depth3 else tmp110)
tmp129 = (tmp130 if depth2 else tmp123)
tmp128 = (tmp129 if depth1 else tmp125)
tmp132 = (tmp116 if depth2 else tmp126)
tmp131 = (tmp132 if depth1 else tmp129)
tmp127 = (tmp128 if s0 else tmp131)
tmp119 = (tmp120 if s1 else tmp127)
tmp138 = (tmp117 if depth4 else tmp98)
tmp137 = (tmp138 if depth3 else tmp116)
tmp136 = (tmp137 if depth2 else tmp130)
tmp135 = (tmp136 if depth1 else tmp132)
tmp142 = (tmp117 if depth4 else tmp104)
tmp141 = (tmp142 if depth3 else tmp116)
tmp140 = (tmp141 if depth2 else tmp116)
tmp139 = (tmp140 if depth1 else tmp136)
tmp134 = (tmp135 if s0 else tmp139)
tmp147 = (tmp117 if depth4 else tmp111)
tmp146 = (tmp147 if depth3 else tmp116)
tmp145 = (tmp146 if depth2 else tmp137)
tmp144 = (tmp145 if depth1 else tmp140)
tmp150 = (tmp117 if depth3 else tmp116)
tmp149 = (tmp150 if depth2 else tmp141)
tmp148 = (tmp149 if depth1 else tmp145)
tmp143 = (tmp144 if s0 else tmp148)
tmp133 = (tmp134 if s1 else tmp143)
tmp118 = (tmp119 if s2 else tmp133)
tmp76 = (tmp77 if s3 else tmp118)
tmp3 = (tmp4 if s4 else tmp76)
tmp159 = (tmp117 if depth3 else tmp138)
tmp158 = (tmp159 if depth2 else tmp146)
tmp157 = (tmp158 if depth1 else tmp149)
tmp162 = (tmp117 if depth3 else tmp142)
tmp161 = (tmp162 if depth2 else tmp150)
tmp160 = (tmp161 if depth1 else tmp158)
tmp156 = (tmp157 if s0 else tmp160)
tmp166 = (tmp117 if depth3 else tmp147)
tmp165 = (tmp166 if depth2 else tmp159)
tmp164 = (tmp165 if depth1 else tmp161)
tmp168 = (tmp117 if depth2 else tmp162)
tmp167 = (tmp168 if depth1 else tmp165)
tmp163 = (tmp164 if s0 else tmp167)
tmp155 = (tmp156 if s1 else tmp163)
tmp175 = (tmp52 if depth5 else tmp99)
tmp174 = (tmp175 if depth4 else tmp117)
tmp173 = (tmp174 if depth3 else tmp117)
tmp172 = (tmp173 if depth2 else tmp166)
tmp171 = (tmp172 if depth1 else tmp168)
tmp180 = (tmp52 if depth5 else tmp105)
tmp179 = (tmp180 if depth4 else tmp117)
tmp178 = (tmp179 if depth3 else tmp117)
tmp177 = (tmp178 if depth2 else tmp117)
tmp176 = (tmp177 if depth1 else tmp172)
tmp170 = (tmp171 if s0 else tmp176)
tmp186 = (tmp52 if depth5 else tmp112)
tmp185 = (tmp186 if depth4 else tmp117)
tmp184 = (tmp185 if depth3 else tmp117)
tmp183 = (tmp184 if depth2 else tmp173)
tmp182 = (tmp183 if depth1 else tmp177)
tmp190 = (tmp52 if depth4 else tmp117)
tmp189 = (tmp190 if depth3 else tmp117)
tmp188 = (tmp189 if depth2 else tmp178)
tmp187 = (tmp188 if depth1 else tmp183)
tmp181 = (tmp182 if s0 else tmp187)
tmp169 = (tmp170 if s1 else tmp181)
tmp154 = (tmp155 if s2 else tmp169)
tmp196 = (tmp190 if depth3 else tmp174)
tmp195 = (tmp196 if depth2 else tmp184)
tmp194 = (tmp195 if depth1 else tmp188)
tmp199 = (tmp190 if depth3 else tmp179)
tmp198 = (tmp199 if depth2 else tmp189)
tmp197 = (tmp198 if depth1 else tmp195)
tmp193 = (tmp194 if s0 else tmp197)
tmp203 = (tmp190 if depth3 else tmp185)
tmp202 = (tmp203 if depth2 else tmp196)
tmp201 = (tmp202 if depth1 else tmp198)
tmp205 = (tmp190 if depth2 else tmp199)
tmp204 = (tmp205 if depth1 else tmp202)
tmp200 = (tmp201 if s0 else tmp204)
tmp192 = (tmp193 if s1 else tmp200)
tmp211 = (tmp52 if depth4 else tmp175)
tmp210 = (tmp211 if depth3 else tmp190)
tmp209 = (tmp210 if depth2 else tmp203)
tmp208 = (tmp209 if depth1 else tmp205)
tmp215 = (tmp52 if depth4 else tmp180)
tmp214 = (tmp215 if depth3 else tmp190)
tmp213 = (tmp214 if depth2 else tmp190)
tmp212 = (tmp213 if depth1 else tmp209)
tmp207 = (tmp208 if s0 else tmp212)
tmp220 = (tmp52 if depth4 else tmp186)
tmp219 = (tmp220 if depth3 else tmp190)
tmp218 = (tmp219 if depth2 else tmp210)
tmp217 = (tmp218 if depth1 else tmp213)
tmp223 = (tmp52 if depth3 else tmp190)
tmp222 = (tmp223 if depth2 else tmp214)
tmp221 = (tmp222 if depth1 else tmp218)
tmp216 = (tmp217 if s0 else tmp221)
tmp206 = (tmp207 if s1 else tmp216)
tmp191 = (tmp192 if s2 else tmp206)
tmp153 = (tmp154 if s3 else tmp191)
tmp230 = (tmp52 if depth3 else tmp211)
tmp229 = (tmp230 if depth2 else tmp219)
tmp228 = (tmp229 if depth1 else tmp222)
tmp233 = (tmp52 if depth3 else tmp215)
tmp232 = (tmp233 if depth2 else tmp223)
tmp231 = (tmp232 if depth1 else tmp229)
tmp227 = (tmp228 if s0 else tmp231)
tmp237 = (tmp52 if depth3 else tmp220)
tmp236 = (tmp237 if depth2 else tmp230)
tmp235 = (tmp236 if depth1 else tmp232)
tmp239 = (tmp52 if depth2 else tmp233)
tmp238 = (tmp239 if depth1 else tmp236)
tmp234 = (tmp235 if s0 else tmp238)
tmp226 = (tmp227 if s1 else tmp234)
tmp248 = (tmp53 if depth7 else tmp66)
tmp247 = (tmp248 if depth6 else tmp52)
tmp246 = (tmp247 if depth5 else tmp52)
tmp245 = (tmp246 if depth4 else tmp52)
tmp244 = (tmp245 if depth3 else tmp52)
tmp243 = (tmp244 if depth2 else tmp237)
tmp242 = (tmp243 if depth1 else tmp239)
tmp255 = (tmp53 if depth7 else tmp58)
tmp254 = (tmp255 if depth6 else tmp52)
tmp253 = (tmp254 if depth5 else tmp52)
tmp252 = (tmp253 if depth4 else tmp52)
tmp251 = (tmp252 if depth3 else tmp52)
tmp250 = (tmp251 if depth2 else tmp52)
tmp249 = (tmp250 if depth1 else tmp243)
tmp241 = (tmp242 if s0 else tmp249)
tmp263 = (tmp53 if depth7 else tmp57)
tmp262 = (tmp263 if depth6 else tmp52)
tmp261 = (tmp262 if depth5 else tmp52)
tmp260 = (tmp261 if depth4 else tmp52)
tmp259 = (tmp260 if depth3 else tmp52)
tmp258 = (tmp259 if depth2 else tmp244)
tmp257 = (tmp258 if depth1 else tmp250)
tmp269 = (tmp53 if depth6 else tmp52)
tmp268 = (tmp269 if depth5 else tmp52)
tmp267 = (tmp268 if depth4 else tmp52)
tmp266 = (tmp267 if depth3 else tmp52)
tmp265 = (tmp266 if depth2 else tmp251)
tmp264 = (tmp265 if depth1 else tmp258)
tmp256 = (tmp257 if s0 else tmp264)
tmp240 = (tmp241 if s1 else tmp256)
tmp225 = (tmp226 if s2 else tmp240)
tmp275 = (tmp267 if depth3 else tmp245)
tmp274 = (tmp275 if depth2 else tmp259)
tmp273 = (tmp274 if depth1 else tmp265)
tmp278 = (tmp267 if depth3 else tmp252)
tmp277 = (tmp278 if depth2 else tmp266)
tmp276 = (tmp277 if depth1 else tmp274)
tmp272 = (tmp273 if s0 else tmp276)
tmp282 = (tmp267 if depth3 else tmp260)
tmp281 = (tmp282 if depth2 else tmp275)
tmp280 = (tmp281 if depth1 else tmp277)
tmp284 = (tmp267 if depth2 else tmp278)
tmp283 = (tmp284 if depth1 else tmp281)
tmp279 = (tmp280 if s0 else tmp283)
tmp271 = (tmp272 if s1 else tmp279)
tmp290 = (tmp268 if depth4 else tmp246)
tmp289 = (tmp290 if depth3 else tmp267)
tmp288 = (tmp289 if depth2 else tmp282)
tmp287 = (tmp288 if depth1 else tmp284)
tmp294 = (tmp268 if depth4 else tmp253)
tmp293 = (tmp294 if depth3 else tmp267)
tmp292 = (tmp293 if depth2 else tmp267)
tmp291 = (tmp292 if depth1 else tmp288)
tmp286 = (tmp287 if s0 else tmp291)
tmp299 = (tmp268 if depth4 else tmp261)
tmp298 = (tmp299 if depth3 else tmp267)
tmp297 = (tmp298 if depth2 else tmp289)
tmp296 = (tmp297 if depth1 else tmp292)
tmp302 = (tmp268 if depth3 else tmp267)
tmp301 = (tmp302 if depth2 else tmp293)
tmp300 = (tmp301 if depth1 else tmp297)
tmp295 = (tmp296 if s0 else tmp300)
tmp285 = (tmp286 if s1 else tmp295)
tmp270 = (tmp271 if s2 else tmp285)
tmp224 = (tmp225 if s3 else tmp270)
tmp152 = (tmp153 if s4 else tmp224)
tmp310 = (tmp268 if depth3 else tmp290)
tmp309 = (tmp310 if depth2 else tmp298)
tmp308 = (tmp309 if depth1 else tmp301)
tmp313 = (tmp268 if depth3 else tmp294)
tmp312 = (tmp313 if depth2 else tmp302)
tmp311 = (tmp312 if depth1 else tmp309)
tmp307 = (tmp308 if s0 else tmp311)
tmp317 = (tmp268 if depth3 else tmp299)
tmp316 = (tmp317 if depth2 else tmp310)
tmp315 = (tmp316 if depth1 else tmp312)
tmp319 = (tmp268 if depth2 else tmp313)
tmp318 = (tmp319 if depth1 else tmp316)
tmp314 = (tmp315 if s0 else tmp318)
tmp306 = (tmp307 if s1 else tmp314)
tmp326 = (tmp269 if depth5 else tmp247)
tmp325 = (tmp326 if depth4 else tmp268)
tmp324 = (tmp325 if depth3 else tmp268)
tmp323 = (tmp324 if depth2 else tmp317)
tmp322 = (tmp323 if depth1 else tmp319)
tmp331 = (tmp269 if depth5 else tmp254)
tmp330 = (tmp331 if depth4 else tmp268)
tmp329 = (tmp330 if depth3 else tmp268)
tmp328 = (tmp329 if depth2 else tmp268)
tmp327 = (tmp328 if depth1 else tmp323)
tmp321 = (tmp322 if s0 else tmp327)
tmp337 = (tmp269 if depth5 else tmp262)
tmp336 = (tmp337 if depth4 else tmp268)
tmp335 = (tmp336 if depth3 else tmp268)
tmp334 = (tmp335 if depth2 else tmp324)
tmp333 = (tmp334 if depth1 else tmp328)
tmp341 = (tmp269 if depth4 else tmp268)
tmp340 = (tmp341 if depth3 else tmp268)
tmp339 = (tmp340 if depth2 else tmp329)
tmp338 = (tmp339 if depth1 else tmp334)
tmp332 = (tmp333 if s0 else tmp338)
tmp320 = (tmp321 if s1 else tmp332)
tmp305 = (tmp306 if s2 else tmp320)
tmp347 = (tmp341 if depth3 else tmp325)
tmp346 = (tmp347 if depth2 else tmp335)
tmp345 = (tmp346 if depth1 else tmp339)
tmp350 = (tmp341 if depth3 else tmp330)
tmp349 = (tmp350 if depth2 else tmp340)
tmp348 = (tmp349 if depth1 else tmp346)
tmp344 = (tmp345 if s0 else tmp348)
tmp354 = (tmp341 if depth3 else tmp336)
tmp353 = (tmp354 if depth2 else tmp347)
tmp352 = (tmp353 if depth1 else tmp349)
tmp356 = (tmp341 if depth2 else tmp350)
tmp355 = (tmp356 if depth1 else tmp353)
tmp351 = (tmp352 if s0 else tmp355)
tmp343 = (tmp344 if s1 else tmp351)
tmp362 = (tmp269 if depth4 else tmp326)
tmp361 = (tmp362 if depth3 else tmp341)
tmp360 = (tmp361 if depth2 else tmp354)
tmp359 = (tmp360 if depth1 else tmp356)
tmp366 = (tmp269 if depth4 else tmp331)
tmp365 = (tmp366 if depth3 else tmp341)
tmp364 = (tmp365 if depth2 else tmp341)
tmp363 = (tmp364 if depth1 else tmp360)
tmp358 = (tmp359 if s0 else tmp363)
tmp371 = (tmp269 if depth4 else tmp337)
tmp370 = (tmp371 if depth3 else tmp341)
tmp369 = (tmp370 if depth2 else tmp361)
tmp368 = (tmp369 if depth1 else tmp364)
tmp374 = (tmp269 if depth3 else tmp341)
tmp373 = (tmp374 if depth2 else tmp365)
tmp372 = (tmp373 if depth1 else tmp369)
tmp367 = (tmp368 if s0 else tmp372)
tmp357 = (tmp358 if s1 else tmp367)
tmp342 = (tmp343 if s2 else tmp357)
tmp304 = (tmp305 if s3 else tmp342)
tmp381 = (tmp269 if depth3 else tmp362)
tmp380 = (tmp381 if depth2 else tmp370)
tmp379 = (tmp380 if depth1 else tmp373)
tmp384 = (tmp269 if depth3 else tmp366)
tmp383 = (tmp384 if depth2 else tmp374)
tmp382 = (tmp383 if depth1 else tmp380)
tmp378 = (tmp379 if s0 else tmp382)
tmp388 = (tmp269 if depth3 else tmp371)
tmp387 = (tmp388 if depth2 else tmp381)
tmp386 = (tmp387 if depth1 else tmp383)
tmp390 = (tmp269 if depth2 else tmp384)
tmp389 = (tmp390 if depth1 else tmp387)
tmp385 = (tmp386 if s0 else tmp389)
tmp377 = (tmp378 if s1 else tmp385)
tmp398 = (tmp53 if depth6 else tmp248)
tmp397 = (tmp398 if depth5 else tmp269)
tmp396 = (tmp397 if depth4 else tmp269)
tmp395 = (tmp396 if depth3 else tmp269)
tmp394 = (tmp395 if depth2 else tmp388)
tmp393 = (tmp394 if depth1 else tmp390)
tmp404 = (tmp53 if depth6 else tmp255)
tmp403 = (tmp404 if depth5 else tmp269)
tmp402 = (tmp403 if depth4 else tmp269)
tmp401 = (tmp402 if depth3 else tmp269)
tmp400 = (tmp401 if depth2 else tmp269)
tmp399 = (tmp400 if depth1 else tmp394)
tmp392 = (tmp393 if s0 else tmp399)
tmp411 = (tmp53 if depth6 else tmp263)
tmp410 = (tmp411 if depth5 else tmp269)
tmp409 = (tmp410 if depth4 else tmp269)
tmp408 = (tmp409 if depth3 else tmp269)
tmp407 = (tmp408 if depth2 else tmp395)
tmp406 = (tmp407 if depth1 else tmp400)
tmp416 = (tmp53 if depth5 else tmp269)
tmp415 = (tmp416 if depth4 else tmp269)
tmp414 = (tmp415 if depth3 else tmp269)
tmp413 = (tmp414 if depth2 else tmp401)
tmp412 = (tmp413 if depth1 else tmp407)
tmp405 = (tmp406 if s0 else tmp412)
tmp391 = (tmp392 if s1 else tmp405)
tmp376 = (tmp377 if s2 else tmp391)
tmp422 = (tmp415 if depth3 else tmp396)
tmp421 = (tmp422 if depth2 else tmp408)
tmp420 = (tmp421 if depth1 else tmp413)
tmp425 = (tmp415 if depth3 else tmp402)
tmp424 = (tmp425 if depth2 else tmp414)
tmp423 = (tmp424 if depth1 else tmp421)
tmp419 = (tmp420 if s0 else tmp423)
tmp429 = (tmp415 if depth3 else tmp409)
tmp428 = (tmp429 if depth2 else tmp422)
tmp427 = (tmp428 if depth1 else tmp424)
tmp431 = (tmp415 if depth2 else tmp425)
tmp430 = (tmp431 if depth1 else tmp428)
tmp426 = (tmp427 if s0 else tmp430)
tmp418 = (tmp419 if s1 else tmp426)
tmp437 = (tmp416 if depth4 else tmp397)
tmp436 = (tmp437 if depth3 else tmp415)
tmp435 = (tmp436 if depth2 else tmp429)
tmp434 = (tmp435 if depth1 else tmp431)
tmp441 = (tmp416 if depth4 else tmp403)
tmp440 = (tmp441 if depth3 else tmp415)
tmp439 = (tmp440 if depth2 else tmp415)
tmp438 = (tmp439 if depth1 else tmp435)
tmp433 = (tmp434 if s0 else tmp438)
tmp446 = (tmp416 if depth4 else tmp410)
tmp445 = (tmp446 if depth3 else tmp415)
tmp444 = (tmp445 if depth2 else tmp436)
tmp443 = (tmp444 if depth1 else tmp439)
tmp449 = (tmp416 if depth3 else tmp415)
tmp448 = (tmp449 if depth2 else tmp440)
tmp447 = (tmp448 if depth1 else tmp444)
tmp442 = (tmp443 if s0 else tmp447)
tmp432 = (tmp433 if s1 else tmp442)
tmp417 = (tmp418 if s2 else tmp432)
tmp375 = (tmp376 if s3 else tmp417)
tmp303 = (tmp304 if s4 else tmp375)
tmp151 = (tmp152 if s5 else tmp303)
tmp2 = (tmp3 if s6 else tmp151)
tmp459 = (tmp416 if depth3 else tmp437)
tmp458 = (tmp459 if depth2 else tmp445)
tmp457 = (tmp458 if depth1 else tmp448)
tmp462 = (tmp416 if depth3 else tmp441)
tmp461 = (tmp462 if depth2 else tmp449)
tmp460 = (tmp461 if depth1 else tmp458)
tmp456 = (tmp457 if s0 else tmp460)
tmp466 = (tmp416 if depth3 else tmp446)
tmp465 = (tmp466 if depth2 else tmp459)
tmp464 = (tmp465 if depth1 else tmp461)
tmp468 = (tmp416 if depth2 else tmp462)
tmp467 = (tmp468 if depth1 else tmp465)
tmp463 = (tmp464 if s0 else tmp467)
tmp455 = (tmp456 if s1 else tmp463)
tmp475 = (tmp53 if depth5 else tmp398)
tmp474 = (tmp475 if depth4 else tmp416)
tmp473 = (tmp474 if depth3 else tmp416)
tmp472 = (tmp473 if depth2 else tmp466)
tmp471 = (tmp472 if depth1 else tmp468)
tmp480 = (tmp53 if depth5 else tmp404)
tmp479 = (tmp480 if depth4 else tmp416)
tmp478 = (tmp479 if depth3 else tmp416)
tmp477 = (tmp478 if depth2 else tmp416)
tmp476 = (tmp477 if depth1 else tmp472)
tmp470 = (tmp471 if s0 else tmp476)
tmp486 = (tmp53 if depth5 else tmp411)
tmp485 = (tmp486 if depth4 else tmp416)
tmp484 = (tmp485 if depth3 else tmp416)
tmp483 = (tmp484 if depth2 else tmp473)
tmp482 = (tmp483 if depth1 else tmp477)
tmp490 = (tmp53 if depth4 else tmp416)
tmp489 = (tmp490 if depth3 else tmp416)
tmp488 = (tmp489 if depth2 else tmp478)
tmp487 = (tmp488 if depth1 else tmp483)
tmp481 = (tmp482 if s0 else tmp487)
tmp469 = (tmp470 if s1 else tmp481)
tmp454 = (tmp455 if s2 else tmp469)
tmp496 = (tmp490 if depth3 else tmp474)
tmp495 = (tmp496 if depth2 else tmp484)
tmp494 = (tmp495 if depth1 else tmp488)
tmp499 = (tmp490 if depth3 else tmp479)
tmp498 = (tmp499 if depth2 else tmp489)
tmp497 = (tmp498 if depth1 else tmp495)
tmp493 = (tmp494 if s0 else tmp497)
tmp503 = (tmp490 if depth3 else tmp485)
tmp502 = (tmp503 if depth2 else tmp496)
tmp501 = (tmp502 if depth1 else tmp498)
tmp505 = (tmp490 if depth2 else tmp499)
tmp504 = (tmp505 if depth1 else tmp502)
tmp500 = (tmp501 if s0 else tmp504)
tmp492 = (tmp493 if s1 else tmp500)
tmp511 = (tmp53 if depth4 else tmp475)
tmp510 = (tmp511 if depth3 else tmp490)
tmp509 = (tmp510 if depth2 else tmp503)
tmp508 = (tmp509 if depth1 else tmp505)
tmp515 = (tmp53 if depth4 else tmp480)
tmp514 = (tmp515 if depth3 else tmp490)
tmp513 = (tmp514 if depth2 else tmp490)
tmp512 = (tmp513 if depth1 else tmp509)
tmp507 = (tmp508 if s0 else tmp512)
tmp520 = (tmp53 if depth4 else tmp486)
tmp519 = (tmp520 if depth3 else tmp490)
tmp518 = (tmp519 if depth2 else tmp510)
tmp517 = (tmp518 if depth1 else tmp513)
tmp523 = (tmp53 if depth3 else tmp490)
tmp522 = (tmp523 if depth2 else tmp514)
tmp521 = (tmp522 if depth1 else tmp518)
tmp516 = (tmp517 if s0 else tmp521)
tmp506 = (tmp507 if s1 else tmp516)
tmp491 = (tmp492 if s2 else tmp506)
tmp453 = (tmp454 if s3 else tmp491)
tmp530 = (tmp53 if depth3 else tmp511)
tmp529 = (tmp530 if depth2 else tmp519)
tmp528 = (tmp529 if depth1 else tmp522)
tmp533 = (tmp53 if depth3 else tmp515)
tmp532 = (tmp533 if depth2 else tmp523)
tmp531 = (tmp532 if depth1 else tmp529)
tmp527 = (tmp528 if s0 else tmp531)
tmp537 = (tmp53 if depth3 else tmp520)
tmp536 = (tmp537 if depth2 else tmp530)
tmp535 = (tmp536 if depth1 else tmp532)
tmp539 = (tmp53 if depth2 else tmp533)
tmp538 = (tmp539 if depth1 else tmp536)
tmp534 = (tmp535 if s0 else tmp538)
tmp526 = (tmp527 if s1 else tmp534)
tmp543 = (tmp53 if depth2 else tmp537)
tmp542 = (tmp543 if depth1 else tmp539)
tmp544 = (tmp53 if depth1 else tmp543)
tmp541 = (tmp542 if s0 else tmp544)
tmp540 = (tmp541 if s1 else tmp5)
tmp525 = (tmp526 if s2 else tmp540)
tmp546 = (tmp46 if s1 else tmp79)
tmp547 = (tmp86 if s1 else tmp93)
tmp545 = (tmp546 if s2 else tmp547)
tmp524 = (tmp525 if s3 else tmp545)
tmp452 = (tmp453 if s4 else tmp524)
tmp551 = (tmp106 if s1 else tmp120)
tmp552 = (tmp127 if s1 else tmp134)
tmp550 = (tmp551 if s2 else tmp552)
tmp554 = (tmp143 if s1 else tmp156)
tmp555 = (tmp163 if s1 else tmp170)
tmp553 = (tmp554 if s2 else tmp555)
tmp549 = (tmp550 if s3 else tmp553)
tmp558 = (tmp181 if s1 else tmp193)
tmp559 = (tmp200 if s1 else tmp207)
tmp557 = (tmp558 if s2 else tmp559)
tmp561 = (tmp216 if s1 else tmp227)
tmp562 = (tmp234 if s1 else tmp241)
tmp560 = (tmp561 if s2 else tmp562)
tmp556 = (tmp557 if s3 else tmp560)
tmp548 = (tmp549 if s4 else tmp556)
tmp451 = (tmp452 if s5 else tmp548)
tmp567 = (tmp256 if s1 else tmp272)
tmp568 = (tmp279 if s1 else tmp286)
tmp566 = (tmp567 if s2 else tmp568)
tmp570 = (tmp295 if s1 else tmp307)
tmp571 = (tmp314 if s1 else tmp321)
tmp569 = (tmp570 if s2 else tmp571)
tmp565 = (tmp566 if s3 else tmp569)
tmp574 = (tmp332 if s1 else tmp344)
tmp575 = (tmp351 if s1 else tmp358)
tmp573 = (tmp574 if s2 else tmp575)
tmp577 = (tmp367 if s1 else tmp378)
tmp578 = (tmp385 if s1 else tmp392)
tmp576 = (tmp577 if s2 else tmp578)
tmp572 = (tmp573 if s3 else tmp576)
tmp564 = (tmp565 if s4 else tmp572)
tmp582 = (tmp405 if s1 else tmp419)
tmp583 = (tmp426 if s1 else tmp433)
tmp581 = (tmp582 if s2 else tmp583)
tmp585 = (tmp442 if s1 else tmp456)
tmp586 = (tmp463 if s1 else tmp470)
tmp584 = (tmp585 if s2 else tmp586)
tmp580 = (tmp581 if s3 else tmp584)
tmp589 = (tmp481 if s1 else tmp493)
tmp590 = (tmp500 if s1 else tmp507)
tmp588 = (tmp589 if s2 else tmp590)
tmp592 = (tmp516 if s1 else tmp527)
tmp593 = (tmp534 if s1 else tmp541)
tmp591 = (tmp592 if s2 else tmp593)
tmp587 = (tmp588 if s3 else tmp591)
tmp579 = (tmp580 if s4 else tmp587)
tmp563 = (tmp564 if s5 else tmp579)
tmp450 = (tmp451 if s6 else tmp563)
tmp1 = (1 - (tmp2 if s7 else tmp450))
action1__s = tmp1
tmp606 = (1 - (1 if action2_1 else 0))
tmp605 = (1 if action4_1 else tmp606)
tmp608 = (1 if action2_1 else 0)
tmp609 = (1 - (1 if action4_1 else tmp606))
tmp607 = (1 - (tmp608 if oxygen_low else tmp609))
tmp604 = (tmp605 if oxygen_full else tmp607)
tmp603 = (tmp604 if depth7 else tmp605)
tmp602 = (tmp603 if depth6 else tmp605)
tmp613 = (tmp604 if k2 else tmp605)
tmp612 = (tmp613 if depth7 else tmp605)
tmp611 = (tmp612 if depth6 else tmp605)
tmp610 = (tmp602 if depth5 else tmp611)
tmp601 = (tmp602 if depth4 else tmp610)
tmp615 = (tmp602 if depth5 else tmp605)
tmp614 = (tmp602 if depth4 else tmp615)
tmp600 = (tmp601 if depth3 else tmp614)
tmp599 = (tmp600 if depth2 else tmp614)
tmp622 = (tmp613 if k1 else tmp605)
tmp621 = (tmp622 if depth7 else tmp605)
tmp620 = (tmp621 if depth6 else tmp605)
tmp619 = (tmp602 if depth5 else tmp620)
tmp618 = (tmp602 if depth4 else tmp619)
tmp617 = (tmp618 if depth3 else tmp614)
tmp628 = (tmp604 if k1 else tmp613)
tmp627 = (tmp628 if depth7 else tmp605)
tmp626 = (tmp627 if depth6 else tmp605)
tmp625 = (tmp602 if depth5 else tmp626)
tmp624 = (tmp625 if depth4 else tmp615)
tmp623 = (tmp614 if depth3 else tmp624)
tmp616 = (tmp617 if depth2 else tmp623)
tmp598 = (tmp599 if depth1 else tmp616)
tmp636 = (tmp605 if oxygen_full else tmp606)
tmp635 = (tmp636 if depth7 else tmp605)
tmp634 = (tmp635 if depth6 else tmp605)
tmp641 = (tmp636 if k2 else tmp605)
tmp640 = (tmp636 if k1 else tmp641)
tmp639 = (tmp640 if depth7 else tmp605)
tmp638 = (tmp639 if depth6 else tmp605)
tmp637 = (tmp634 if depth5 else tmp638)
tmp633 = (tmp634 if depth4 else tmp637)
tmp643 = (tmp634 if depth5 else tmp605)
tmp642 = (tmp634 if depth4 else tmp643)
tmp632 = (tmp633 if depth3 else tmp642)
tmp649 = (tmp641 if k1 else tmp605)
tmp648 = (tmp649 if depth7 else tmp605)
tmp647 = (tmp648 if depth6 else tmp605)
tmp646 = (tmp634 if depth5 else tmp647)
tmp645 = (tmp634 if depth4 else tmp646)
tmp644 = (tmp645 if depth3 else tmp642)
tmp631 = (tmp632 if depth2 else tmp644)
tmp655 = (tmp641 if depth7 else tmp605)
tmp654 = (tmp655 if depth6 else tmp605)
tmp653 = (tmp634 if depth5 else tmp654)
tmp652 = (tmp634 if depth4 else tmp653)
tmp651 = (tmp652 if depth3 else tmp642)
tmp650 = (tmp651 if depth2 else tmp642)
tmp630 = (tmp631 if depth1 else tmp650)
tmp658 = (tmp634 if depth3 else tmp642)
tmp657 = (tmp658 if depth2 else tmp651)
tmp656 = (tmp657 if depth1 else tmp631)
tmp629 = (tmp630 if s0 else tmp656)
tmp597 = (tmp598 if s1 else tmp629)
tmp665 = (tmp634 if depth3 else tmp645)
tmp664 = (tmp665 if depth2 else tmp632)
tmp663 = (tmp664 if depth1 else tmp657)
tmp668 = (tmp634 if depth3 else tmp652)
tmp667 = (tmp668 if depth2 else tmp658)
tmp666 = (tmp667 if depth1 else tmp664)
tmp662 = (tmp663 if s0 else tmp666)
tmp672 = (tmp634 if depth3 else tmp633)
tmp671 = (tmp672 if depth2 else tmp665)
tmp670 = (tmp671 if depth1 else tmp667)
tmp674 = (tmp634 if depth2 else tmp668)
tmp673 = (tmp674 if depth1 else tmp671)
tmp669 = (tmp670 if s0 else tmp673)
tmp661 = (tmp662 if s1 else tmp669)
tmp682 = (tmp635 if depth6 else tmp648)
tmp681 = (tmp682 if depth5 else tmp634)
tmp680 = (tmp681 if depth4 else tmp634)
tmp679 = (tmp680 if depth3 else tmp634)
tmp678 = (tmp679 if depth2 else tmp672)
tmp677 = (tmp678 if depth1 else tmp674)
tmp688 = (tmp635 if depth6 else tmp655)
tmp687 = (tmp688 if depth5 else tmp634)
tmp686 = (tmp687 if depth4 else tmp634)
tmp685 = (tmp686 if depth3 else tmp634)
tmp684 = (tmp685 if depth2 else tmp634)
tmp683 = (tmp684 if depth1 else tmp678)
tmp676 = (tmp677 if s0 else tmp683)
tmp695 = (tmp635 if depth6 else tmp639)
tmp694 = (tmp695 if depth5 else tmp634)
tmp693 = (tmp694 if depth4 else tmp634)
tmp692 = (tmp693 if depth3 else tmp634)
tmp691 = (tmp692 if depth2 else tmp679)
tmp690 = (tmp691 if depth1 else tmp684)
tmp700 = (tmp635 if depth5 else tmp634)
tmp699 = (tmp700 if depth4 else tmp634)
tmp698 = (tmp699 if depth3 else tmp634)
tmp697 = (tmp698 if depth2 else tmp685)
tmp696 = (tmp697 if depth1 else tmp691)
tmp689 = (tmp690 if s0 else tmp696)
tmp675 = (tmp676 if s1 else tmp689)
tmp660 = (tmp661 if s2 else tmp675)
tmp706 = (tmp699 if depth3 else tmp680)
tmp705 = (tmp706 if depth2 else tmp692)
tmp704 = (tmp705 if depth1 else tmp697)
tmp709 = (tmp699 if depth3 else tmp686)
tmp708 = (tmp709 if depth2 else tmp698)
tmp707 = (tmp708 if depth1 else tmp705)
tmp703 = (tmp704 if s0 else tmp707)
tmp713 = (tmp699 if depth3 else tmp693)
tmp712 = (tmp713 if depth2 else tmp706)
tmp711 = (tmp712 if depth1 else tmp708)
tmp715 = (tmp699 if depth2 else tmp709)
tmp714 = (tmp715 if depth1 else tmp712)
tmp710 = (tmp711 if s0 else tmp714)
tmp702 = (tmp703 if s1 else tmp710)
tmp721 = (tmp700 if depth4 else tmp681)
tmp720 = (tmp721 if depth3 else tmp699)
tmp719 = (tmp720 if depth2 else tmp713)
tmp718 = (tmp719 if depth1 else tmp715)
tmp725 = (tmp700 if depth4 else tmp687)
tmp724 = (tmp725 if depth3 else tmp699)
tmp723 = (tmp724 if depth2 else tmp699)
tmp722 = (tmp723 if depth1 else tmp719)
tmp717 = (tmp718 if s0 else tmp722)
tmp730 = (tmp700 if depth4 else tmp694)
tmp729 = (tmp730 if depth3 else tmp699)
tmp728 = (tmp729 if depth2 else tmp720)
tmp727 = (tmp728 if depth1 else tmp723)
tmp733 = (tmp700 if depth3 else tmp699)
tmp732 = (tmp733 if depth2 else tmp724)
tmp731 = (tmp732 if depth1 else tmp728)
tmp726 = (tmp727 if s0 else tmp731)
tmp716 = (tmp717 if s1 else tmp726)
tmp701 = (tmp702 if s2 else tmp716)
tmp659 = (tmp660 if s3 else tmp701)
tmp596 = (tmp597 if s4 else tmp659)
tmp742 = (tmp700 if depth3 else tmp721)
tmp741 = (tmp742 if depth2 else tmp729)
tmp740 = (tmp741 if depth1 else tmp732)
tmp745 = (tmp700 if depth3 else tmp725)
tmp744 = (tmp745 if depth2 else tmp733)
tmp743 = (tmp744 if depth1 else tmp741)
tmp739 = (tmp740 if s0 else tmp743)
tmp749 = (tmp700 if depth3 else tmp730)
tmp748 = (tmp749 if depth2 else tmp742)
tmp747 = (tmp748 if depth1 else tmp744)
tmp751 = (tmp700 if depth2 else tmp745)
tmp750 = (tmp751 if depth1 else tmp748)
tmp746 = (tmp747 if s0 else tmp750)
tmp738 = (tmp739 if s1 else tmp746)
tmp758 = (tmp635 if depth5 else tmp682)
tmp757 = (tmp758 if depth4 else tmp700)
tmp756 = (tmp757 if depth3 else tmp700)
tmp755 = (tmp756 if depth2 else tmp749)
tmp754 = (tmp755 if depth1 else tmp751)
tmp763 = (tmp635 if depth5 else tmp688)
tmp762 = (tmp763 if depth4 else tmp700)
tmp761 = (tmp762 if depth3 else tmp700)
tmp760 = (tmp761 if depth2 else tmp700)
tmp759 = (tmp760 if depth1 else tmp755)
tmp753 = (tmp754 if s0 else tmp759)
tmp769 = (tmp635 if depth5 else tmp695)
tmp768 = (tmp769 if depth4 else tmp700)
tmp767 = (tmp768 if depth3 else tmp700)
tmp766 = (tmp767 if depth2 else tmp756)
tmp765 = (tmp766 if depth1 else tmp760)
tmp773 = (tmp635 if depth4 else tmp700)
tmp772 = (tmp773 if depth3 else tmp700)
tmp771 = (tmp772 if depth2 else tmp761)
tmp770 = (tmp771 if depth1 else tmp766)
tmp764 = (tmp765 if s0 else tmp770)
tmp752 = (tmp753 if s1 else tmp764)
tmp737 = (tmp738 if s2 else tmp752)
tmp779 = (tmp773 if depth3 else tmp757)
tmp778 = (tmp779 if depth2 else tmp767)
tmp777 = (tmp778 if depth1 else tmp771)
tmp782 = (tmp773 if depth3 else tmp762)
tmp781 = (tmp782 if depth2 else tmp772)
tmp780 = (tmp781 if depth1 else tmp778)
tmp776 = (tmp777 if s0 else tmp780)
tmp786 = (tmp773 if depth3 else tmp768)
tmp785 = (tmp786 if depth2 else tmp779)
tmp784 = (tmp785 if depth1 else tmp781)
tmp788 = (tmp773 if depth2 else tmp782)
tmp787 = (tmp788 if depth1 else tmp785)
tmp783 = (tmp784 if s0 else tmp787)
tmp775 = (tmp776 if s1 else tmp783)
tmp794 = (tmp635 if depth4 else tmp758)
tmp793 = (tmp794 if depth3 else tmp773)
tmp792 = (tmp793 if depth2 else tmp786)
tmp791 = (tmp792 if depth1 else tmp788)
tmp798 = (tmp635 if depth4 else tmp763)
tmp797 = (tmp798 if depth3 else tmp773)
tmp796 = (tmp797 if depth2 else tmp773)
tmp795 = (tmp796 if depth1 else tmp792)
tmp790 = (tmp791 if s0 else tmp795)
tmp803 = (tmp635 if depth4 else tmp769)
tmp802 = (tmp803 if depth3 else tmp773)
tmp801 = (tmp802 if depth2 else tmp793)
tmp800 = (tmp801 if depth1 else tmp796)
tmp806 = (tmp635 if depth3 else tmp773)
tmp805 = (tmp806 if depth2 else tmp797)
tmp804 = (tmp805 if depth1 else tmp801)
tmp799 = (tmp800 if s0 else tmp804)
tmp789 = (tmp790 if s1 else tmp799)
tmp774 = (tmp775 if s2 else tmp789)
tmp736 = (tmp737 if s3 else tmp774)
tmp813 = (tmp635 if depth3 else tmp794)
tmp812 = (tmp813 if depth2 else tmp802)
tmp811 = (tmp812 if depth1 else tmp805)
tmp816 = (tmp635 if depth3 else tmp798)
tmp815 = (tmp816 if depth2 else tmp806)
tmp814 = (tmp815 if depth1 else tmp812)
tmp810 = (tmp811 if s0 else tmp814)
tmp820 = (tmp635 if depth3 else tmp803)
tmp819 = (tmp820 if depth2 else tmp813)
tmp818 = (tmp819 if depth1 else tmp815)
tmp822 = (tmp635 if depth2 else tmp816)
tmp821 = (tmp822 if depth1 else tmp819)
tmp817 = (tmp818 if s0 else tmp821)
tmp809 = (tmp810 if s1 else tmp817)
tmp831 = (tmp636 if depth7 else tmp649)
tmp830 = (tmp831 if depth6 else tmp635)
tmp829 = (tmp830 if depth5 else tmp635)
tmp828 = (tmp829 if depth4 else tmp635)
tmp827 = (tmp828 if depth3 else tmp635)
tmp826 = (tmp827 if depth2 else tmp820)
tmp825 = (tmp826 if depth1 else tmp822)
tmp838 = (tmp636 if depth7 else tmp641)
tmp837 = (tmp838 if depth6 else tmp635)
tmp836 = (tmp837 if depth5 else tmp635)
tmp835 = (tmp836 if depth4 else tmp635)
tmp834 = (tmp835 if depth3 else tmp635)
tmp833 = (tmp834 if depth2 else tmp635)
tmp832 = (tmp833 if depth1 else tmp826)
tmp824 = (tmp825 if s0 else tmp832)
tmp846 = (tmp636 if depth7 else tmp640)
tmp845 = (tmp846 if depth6 else tmp635)
tmp844 = (tmp845 if depth5 else tmp635)
tmp843 = (tmp844 if depth4 else tmp635)
tmp842 = (tmp843 if depth3 else tmp635)
tmp841 = (tmp842 if depth2 else tmp827)
tmp840 = (tmp841 if depth1 else tmp833)
tmp852 = (tmp636 if depth6 else tmp635)
tmp851 = (tmp852 if depth5 else tmp635)
tmp850 = (tmp851 if depth4 else tmp635)
tmp849 = (tmp850 if depth3 else tmp635)
tmp848 = (tmp849 if depth2 else tmp834)
tmp847 = (tmp848 if depth1 else tmp841)
tmp839 = (tmp840 if s0 else tmp847)
tmp823 = (tmp824 if s1 else tmp839)
tmp808 = (tmp809 if s2 else tmp823)
tmp858 = (tmp850 if depth3 else tmp828)
tmp857 = (tmp858 if depth2 else tmp842)
tmp856 = (tmp857 if depth1 else tmp848)
tmp861 = (tmp850 if depth3 else tmp835)
tmp860 = (tmp861 if depth2 else tmp849)
tmp859 = (tmp860 if depth1 else tmp857)
tmp855 = (tmp856 if s0 else tmp859)
tmp865 = (tmp850 if depth3 else tmp843)
tmp864 = (tmp865 if depth2 else tmp858)
tmp863 = (tmp864 if depth1 else tmp860)
tmp867 = (tmp850 if depth2 else tmp861)
tmp866 = (tmp867 if depth1 else tmp864)
tmp862 = (tmp863 if s0 else tmp866)
tmp854 = (tmp855 if s1 else tmp862)
tmp873 = (tmp851 if depth4 else tmp829)
tmp872 = (tmp873 if depth3 else tmp850)
tmp871 = (tmp872 if depth2 else tmp865)
tmp870 = (tmp871 if depth1 else tmp867)
tmp877 = (tmp851 if depth4 else tmp836)
tmp876 = (tmp877 if depth3 else tmp850)
tmp875 = (tmp876 if depth2 else tmp850)
tmp874 = (tmp875 if depth1 else tmp871)
tmp869 = (tmp870 if s0 else tmp874)
tmp882 = (tmp851 if depth4 else tmp844)
tmp881 = (tmp882 if depth3 else tmp850)
tmp880 = (tmp881 if depth2 else tmp872)
tmp879 = (tmp880 if depth1 else tmp875)
tmp885 = (tmp851 if depth3 else tmp850)
tmp884 = (tmp885 if depth2 else tmp876)
tmp883 = (tmp884 if depth1 else tmp880)
tmp878 = (tmp879 if s0 else tmp883)
tmp868 = (tmp869 if s1 else tmp878)
tmp853 = (tmp854 if s2 else tmp868)
tmp807 = (tmp808 if s3 else tmp853)
tmp735 = (tmp736 if s4 else tmp807)
tmp893 = (tmp851 if depth3 else tmp873)
tmp892 = (tmp893 if depth2 else tmp881)
tmp891 = (tmp892 if depth1 else tmp884)
tmp896 = (tmp851 if depth3 else tmp877)
tmp895 = (tmp896 if depth2 else tmp885)
tmp894 = (tmp895 if depth1 else tmp892)
tmp890 = (tmp891 if s0 else tmp894)
tmp900 = (tmp851 if depth3 else tmp882)
tmp899 = (tmp900 if depth2 else tmp893)
tmp898 = (tmp899 if depth1 else tmp895)
tmp902 = (tmp851 if depth2 else tmp896)
tmp901 = (tmp902 if depth1 else tmp899)
tmp897 = (tmp898 if s0 else tmp901)
tmp889 = (tmp890 if s1 else tmp897)
tmp909 = (tmp852 if depth5 else tmp830)
tmp908 = (tmp909 if depth4 else tmp851)
tmp907 = (tmp908 if depth3 else tmp851)
tmp906 = (tmp907 if depth2 else tmp900)
tmp905 = (tmp906 if depth1 else tmp902)
tmp914 = (tmp852 if depth5 else tmp837)
tmp913 = (tmp914 if depth4 else tmp851)
tmp912 = (tmp913 if depth3 else tmp851)
tmp911 = (tmp912 if depth2 else tmp851)
tmp910 = (tmp911 if depth1 else tmp906)
tmp904 = (tmp905 if s0 else tmp910)
tmp920 = (tmp852 if depth5 else tmp845)
tmp919 = (tmp920 if depth4 else tmp851)
tmp918 = (tmp919 if depth3 else tmp851)
tmp917 = (tmp918 if depth2 else tmp907)
tmp916 = (tmp917 if depth1 else tmp911)
tmp924 = (tmp852 if depth4 else tmp851)
tmp923 = (tmp924 if depth3 else tmp851)
tmp922 = (tmp923 if depth2 else tmp912)
tmp921 = (tmp922 if depth1 else tmp917)
tmp915 = (tmp916 if s0 else tmp921)
tmp903 = (tmp904 if s1 else tmp915)
tmp888 = (tmp889 if s2 else tmp903)
tmp930 = (tmp924 if depth3 else tmp908)
tmp929 = (tmp930 if depth2 else tmp918)
tmp928 = (tmp929 if depth1 else tmp922)
tmp933 = (tmp924 if depth3 else tmp913)
tmp932 = (tmp933 if depth2 else tmp923)
tmp931 = (tmp932 if depth1 else tmp929)
tmp927 = (tmp928 if s0 else tmp931)
tmp937 = (tmp924 if depth3 else tmp919)
tmp936 = (tmp937 if depth2 else tmp930)
tmp935 = (tmp936 if depth1 else tmp932)
tmp939 = (tmp924 if depth2 else tmp933)
tmp938 = (tmp939 if depth1 else tmp936)
tmp934 = (tmp935 if s0 else tmp938)
tmp926 = (tmp927 if s1 else tmp934)
tmp945 = (tmp852 if depth4 else tmp909)
tmp944 = (tmp945 if depth3 else tmp924)
tmp943 = (tmp944 if depth2 else tmp937)
tmp942 = (tmp943 if depth1 else tmp939)
tmp949 = (tmp852 if depth4 else tmp914)
tmp948 = (tmp949 if depth3 else tmp924)
tmp947 = (tmp948 if depth2 else tmp924)
tmp946 = (tmp947 if depth1 else tmp943)
tmp941 = (tmp942 if s0 else tmp946)
tmp954 = (tmp852 if depth4 else tmp920)
tmp953 = (tmp954 if depth3 else tmp924)
tmp952 = (tmp953 if depth2 else tmp944)
tmp951 = (tmp952 if depth1 else tmp947)
tmp957 = (tmp852 if depth3 else tmp924)
tmp956 = (tmp957 if depth2 else tmp948)
tmp955 = (tmp956 if depth1 else tmp952)
tmp950 = (tmp951 if s0 else tmp955)
tmp940 = (tmp941 if s1 else tmp950)
tmp925 = (tmp926 if s2 else tmp940)
tmp887 = (tmp888 if s3 else tmp925)
tmp964 = (tmp852 if depth3 else tmp945)
tmp963 = (tmp964 if depth2 else tmp953)
tmp962 = (tmp963 if depth1 else tmp956)
tmp967 = (tmp852 if depth3 else tmp949)
tmp966 = (tmp967 if depth2 else tmp957)
tmp965 = (tmp966 if depth1 else tmp963)
tmp961 = (tmp962 if s0 else tmp965)
tmp971 = (tmp852 if depth3 else tmp954)
tmp970 = (tmp971 if depth2 else tmp964)
tmp969 = (tmp970 if depth1 else tmp966)
tmp973 = (tmp852 if depth2 else tmp967)
tmp972 = (tmp973 if depth1 else tmp970)
tmp968 = (tmp969 if s0 else tmp972)
tmp960 = (tmp961 if s1 else tmp968)
tmp981 = (tmp636 if depth6 else tmp831)
tmp980 = (tmp981 if depth5 else tmp852)
tmp979 = (tmp980 if depth4 else tmp852)
tmp978 = (tmp979 if depth3 else tmp852)
tmp977 = (tmp978 if depth2 else tmp971)
tmp976 = (tmp977 if depth1 else tmp973)
tmp987 = (tmp636 if depth6 else tmp838)
tmp986 = (tmp987 if depth5 else tmp852)
tmp985 = (tmp986 if depth4 else tmp852)
tmp984 = (tmp985 if depth3 else tmp852)
tmp983 = (tmp984 if depth2 else tmp852)
tmp982 = (tmp983 if depth1 else tmp977)
tmp975 = (tmp976 if s0 else tmp982)
tmp994 = (tmp636 if depth6 else tmp846)
tmp993 = (tmp994 if depth5 else tmp852)
tmp992 = (tmp993 if depth4 else tmp852)
tmp991 = (tmp992 if depth3 else tmp852)
tmp990 = (tmp991 if depth2 else tmp978)
tmp989 = (tmp990 if depth1 else tmp983)
tmp999 = (tmp636 if depth5 else tmp852)
tmp998 = (tmp999 if depth4 else tmp852)
tmp997 = (tmp998 if depth3 else tmp852)
tmp996 = (tmp997 if depth2 else tmp984)
tmp995 = (tmp996 if depth1 else tmp990)
tmp988 = (tmp989 if s0 else tmp995)
tmp974 = (tmp975 if s1 else tmp988)
tmp959 = (tmp960 if s2 else tmp974)
tmp1005 = (tmp998 if depth3 else tmp979)
tmp1004 = (tmp1005 if depth2 else tmp991)
tmp1003 = (tmp1004 if depth1 else tmp996)
tmp1008 = (tmp998 if depth3 else tmp985)
tmp1007 = (tmp1008 if depth2 else tmp997)
tmp1006 = (tmp1007 if depth1 else tmp1004)
tmp1002 = (tmp1003 if s0 else tmp1006)
tmp1012 = (tmp998 if depth3 else tmp992)
tmp1011 = (tmp1012 if depth2 else tmp1005)
tmp1010 = (tmp1011 if depth1 else tmp1007)
tmp1014 = (tmp998 if depth2 else tmp1008)
tmp1013 = (tmp1014 if depth1 else tmp1011)
tmp1009 = (tmp1010 if s0 else tmp1013)
tmp1001 = (tmp1002 if s1 else tmp1009)
tmp1020 = (tmp999 if depth4 else tmp980)
tmp1019 = (tmp1020 if depth3 else tmp998)
tmp1018 = (tmp1019 if depth2 else tmp1012)
tmp1017 = (tmp1018 if depth1 else tmp1014)
tmp1024 = (tmp999 if depth4 else tmp986)
tmp1023 = (tmp1024 if depth3 else tmp998)
tmp1022 = (tmp1023 if depth2 else tmp998)
tmp1021 = (tmp1022 if depth1 else tmp1018)
tmp1016 = (tmp1017 if s0 else tmp1021)
tmp1029 = (tmp999 if depth4 else tmp993)
tmp1028 = (tmp1029 if depth3 else tmp998)
tmp1027 = (tmp1028 if depth2 else tmp1019)
tmp1026 = (tmp1027 if depth1 else tmp1022)
tmp1032 = (tmp999 if depth3 else tmp998)
tmp1031 = (tmp1032 if depth2 else tmp1023)
tmp1030 = (tmp1031 if depth1 else tmp1027)
tmp1025 = (tmp1026 if s0 else tmp1030)
tmp1015 = (tmp1016 if s1 else tmp1025)
tmp1000 = (tmp1001 if s2 else tmp1015)
tmp958 = (tmp959 if s3 else tmp1000)
tmp886 = (tmp887 if s4 else tmp958)
tmp734 = (tmp735 if s5 else tmp886)
tmp595 = (tmp596 if s6 else tmp734)
tmp1042 = (tmp999 if depth3 else tmp1020)
tmp1041 = (tmp1042 if depth2 else tmp1028)
tmp1040 = (tmp1041 if depth1 else tmp1031)
tmp1045 = (tmp999 if depth3 else tmp1024)
tmp1044 = (tmp1045 if depth2 else tmp1032)
tmp1043 = (tmp1044 if depth1 else tmp1041)
tmp1039 = (tmp1040 if s0 else tmp1043)
tmp1049 = (tmp999 if depth3 else tmp1029)
tmp1048 = (tmp1049 if depth2 else tmp1042)
tmp1047 = (tmp1048 if depth1 else tmp1044)
tmp1051 = (tmp999 if depth2 else tmp1045)
tmp1050 = (tmp1051 if depth1 else tmp1048)
tmp1046 = (tmp1047 if s0 else tmp1050)
tmp1038 = (tmp1039 if s1 else tmp1046)
tmp1058 = (tmp636 if depth5 else tmp981)
tmp1057 = (tmp1058 if depth4 else tmp999)
tmp1056 = (tmp1057 if depth3 else tmp999)
tmp1055 = (tmp1056 if depth2 else tmp1049)
tmp1054 = (tmp1055 if depth1 else tmp1051)
tmp1063 = (tmp636 if depth5 else tmp987)
tmp1062 = (tmp1063 if depth4 else tmp999)
tmp1061 = (tmp1062 if depth3 else tmp999)
tmp1060 = (tmp1061 if depth2 else tmp999)
tmp1059 = (tmp1060 if depth1 else tmp1055)
tmp1053 = (tmp1054 if s0 else tmp1059)
tmp1069 = (tmp636 if depth5 else tmp994)
tmp1068 = (tmp1069 if depth4 else tmp999)
tmp1067 = (tmp1068 if depth3 else tmp999)
tmp1066 = (tmp1067 if depth2 else tmp1056)
tmp1065 = (tmp1066 if depth1 else tmp1060)
tmp1073 = (tmp636 if depth4 else tmp999)
tmp1072 = (tmp1073 if depth3 else tmp999)
tmp1071 = (tmp1072 if depth2 else tmp1061)
tmp1070 = (tmp1071 if depth1 else tmp1066)
tmp1064 = (tmp1065 if s0 else tmp1070)
tmp1052 = (tmp1053 if s1 else tmp1064)
tmp1037 = (tmp1038 if s2 else tmp1052)
tmp1079 = (tmp1073 if depth3 else tmp1057)
tmp1078 = (tmp1079 if depth2 else tmp1067)
tmp1077 = (tmp1078 if depth1 else tmp1071)
tmp1082 = (tmp1073 if depth3 else tmp1062)
tmp1081 = (tmp1082 if depth2 else tmp1072)
tmp1080 = (tmp1081 if depth1 else tmp1078)
tmp1076 = (tmp1077 if s0 else tmp1080)
tmp1086 = (tmp1073 if depth3 else tmp1068)
tmp1085 = (tmp1086 if depth2 else tmp1079)
tmp1084 = (tmp1085 if depth1 else tmp1081)
tmp1088 = (tmp1073 if depth2 else tmp1082)
tmp1087 = (tmp1088 if depth1 else tmp1085)
tmp1083 = (tmp1084 if s0 else tmp1087)
tmp1075 = (tmp1076 if s1 else tmp1083)
tmp1094 = (tmp636 if depth4 else tmp1058)
tmp1093 = (tmp1094 if depth3 else tmp1073)
tmp1092 = (tmp1093 if depth2 else tmp1086)
tmp1091 = (tmp1092 if depth1 else tmp1088)
tmp1098 = (tmp636 if depth4 else tmp1063)
tmp1097 = (tmp1098 if depth3 else tmp1073)
tmp1096 = (tmp1097 if depth2 else tmp1073)
tmp1095 = (tmp1096 if depth1 else tmp1092)
tmp1090 = (tmp1091 if s0 else tmp1095)
tmp1103 = (tmp636 if depth4 else tmp1069)
tmp1102 = (tmp1103 if depth3 else tmp1073)
tmp1101 = (tmp1102 if depth2 else tmp1093)
tmp1100 = (tmp1101 if depth1 else tmp1096)
tmp1106 = (tmp636 if depth3 else tmp1073)
tmp1105 = (tmp1106 if depth2 else tmp1097)
tmp1104 = (tmp1105 if depth1 else tmp1101)
tmp1099 = (tmp1100 if s0 else tmp1104)
tmp1089 = (tmp1090 if s1 else tmp1099)
tmp1074 = (tmp1075 if s2 else tmp1089)
tmp1036 = (tmp1037 if s3 else tmp1074)
tmp1113 = (tmp636 if depth3 else tmp1094)
tmp1112 = (tmp1113 if depth2 else tmp1102)
tmp1111 = (tmp1112 if depth1 else tmp1105)
tmp1116 = (tmp636 if depth3 else tmp1098)
tmp1115 = (tmp1116 if depth2 else tmp1106)
tmp1114 = (tmp1115 if depth1 else tmp1112)
tmp1110 = (tmp1111 if s0 else tmp1114)
tmp1120 = (tmp636 if depth3 else tmp1103)
tmp1119 = (tmp1120 if depth2 else tmp1113)
tmp1118 = (tmp1119 if depth1 else tmp1115)
tmp1122 = (tmp636 if depth2 else tmp1116)
tmp1121 = (tmp1122 if depth1 else tmp1119)
tmp1117 = (tmp1118 if s0 else tmp1121)
tmp1109 = (tmp1110 if s1 else tmp1117)
tmp1126 = (tmp636 if depth2 else tmp1120)
tmp1125 = (tmp1126 if depth1 else tmp1122)
tmp1127 = (tmp636 if depth1 else tmp1126)
tmp1124 = (tmp1125 if s0 else tmp1127)
tmp1123 = (tmp1124 if s1 else tmp598)
tmp1108 = (tmp1109 if s2 else tmp1123)
tmp1129 = (tmp629 if s1 else tmp662)
tmp1130 = (tmp669 if s1 else tmp676)
tmp1128 = (tmp1129 if s2 else tmp1130)
tmp1107 = (tmp1108 if s3 else tmp1128)
tmp1035 = (tmp1036 if s4 else tmp1107)
tmp1134 = (tmp689 if s1 else tmp703)
tmp1135 = (tmp710 if s1 else tmp717)
tmp1133 = (tmp1134 if s2 else tmp1135)
tmp1137 = (tmp726 if s1 else tmp739)
tmp1138 = (tmp746 if s1 else tmp753)
tmp1136 = (tmp1137 if s2 else tmp1138)
tmp1132 = (tmp1133 if s3 else tmp1136)
tmp1141 = (tmp764 if s1 else tmp776)
tmp1142 = (tmp783 if s1 else tmp790)
tmp1140 = (tmp1141 if s2 else tmp1142)
tmp1144 = (tmp799 if s1 else tmp810)
tmp1145 = (tmp817 if s1 else tmp824)
tmp1143 = (tmp1144 if s2 else tmp1145)
tmp1139 = (tmp1140 if s3 else tmp1143)
tmp1131 = (tmp1132 if s4 else tmp1139)
tmp1034 = (tmp1035 if s5 else tmp1131)
tmp1150 = (tmp839 if s1 else tmp855)
tmp1151 = (tmp862 if s1 else tmp869)
tmp1149 = (tmp1150 if s2 else tmp1151)
tmp1153 = (tmp878 if s1 else tmp890)
tmp1154 = (tmp897 if s1 else tmp904)
tmp1152 = (tmp1153 if s2 else tmp1154)
tmp1148 = (tmp1149 if s3 else tmp1152)
tmp1157 = (tmp915 if s1 else tmp927)
tmp1158 = (tmp934 if s1 else tmp941)
tmp1156 = (tmp1157 if s2 else tmp1158)
tmp1160 = (tmp950 if s1 else tmp961)
tmp1161 = (tmp968 if s1 else tmp975)
tmp1159 = (tmp1160 if s2 else tmp1161)
tmp1155 = (tmp1156 if s3 else tmp1159)
tmp1147 = (tmp1148 if s4 else tmp1155)
tmp1165 = (tmp988 if s1 else tmp1002)
tmp1166 = (tmp1009 if s1 else tmp1016)
tmp1164 = (tmp1165 if s2 else tmp1166)
tmp1168 = (tmp1025 if s1 else tmp1039)
tmp1169 = (tmp1046 if s1 else tmp1053)
tmp1167 = (tmp1168 if s2 else tmp1169)
tmp1163 = (tmp1164 if s3 else tmp1167)
tmp1172 = (tmp1064 if s1 else tmp1076)
tmp1173 = (tmp1083 if s1 else tmp1090)
tmp1171 = (tmp1172 if s2 else tmp1173)
tmp1175 = (tmp1099 if s1 else tmp1110)
tmp1176 = (tmp1117 if s1 else tmp1124)
tmp1174 = (tmp1175 if s2 else tmp1176)
tmp1170 = (tmp1171 if s3 else tmp1174)
tmp1162 = (tmp1163 if s4 else tmp1170)
tmp1146 = (tmp1147 if s5 else tmp1162)
tmp1033 = (tmp1034 if s6 else tmp1146)
tmp594 = (1 - (tmp595 if s7 else tmp1033))
action2__s = tmp594
tmp1189 = (1 - (1 if action3_1 else 0))
tmp1188 = (1 if action4_1 else tmp1189)
tmp1193 = (1 if action2_1 else 0)
tmp1192 = (1 if action3_1 else tmp1193)
tmp1191 = (1 if action4_1 else tmp1192)
tmp1194 = (1 - (1 if action4_1 else tmp1189))
tmp1190 = (1 - (tmp1191 if oxygen_low else tmp1194))
tmp1187 = (tmp1188 if oxygen_full else tmp1190)
tmp1186 = (tmp1187 if depth7 else tmp1188)
tmp1185 = (tmp1186 if depth6 else tmp1188)
tmp1198 = (tmp1187 if k2 else tmp1188)
tmp1197 = (tmp1198 if depth7 else tmp1188)
tmp1196 = (tmp1197 if depth6 else tmp1188)
tmp1195 = (tmp1185 if depth5 else tmp1196)
tmp1184 = (tmp1185 if depth4 else tmp1195)
tmp1209 = (1 if action1_1 else 0)
tmp1208 = (tmp1209 if action2_1 else 1)
tmp1207 = (1 - (tmp1208 if action3_1 else 0))
tmp1206 = (1 if action4_1 else tmp1207)
tmp1205 = (tmp1188 if oxygen_low else tmp1206)
tmp1204 = (tmp1188 if oxygen_full else tmp1205)
tmp1203 = (tmp1188 if diver_found else tmp1204)
tmp1202 = (tmp1188 if depth7 else tmp1203)
tmp1201 = (tmp1188 if depth6 else tmp1202)
tmp1200 = (tmp1185 if depth5 else tmp1201)
tmp1199 = (tmp1185 if depth4 else tmp1200)
tmp1183 = (tmp1184 if depth3 else tmp1199)
tmp1212 = (tmp1185 if depth5 else tmp1188)
tmp1211 = (tmp1185 if depth4 else tmp1212)
tmp1210 = (tmp1211 if depth3 else tmp1199)
tmp1182 = (tmp1183 if depth2 else tmp1210)
tmp1219 = (tmp1198 if k1 else tmp1188)
tmp1218 = (tmp1219 if depth7 else tmp1188)
tmp1217 = (tmp1218 if depth6 else tmp1188)
tmp1216 = (tmp1185 if depth5 else tmp1217)
tmp1215 = (tmp1185 if depth4 else tmp1216)
tmp1214 = (tmp1215 if depth3 else tmp1199)
tmp1225 = (tmp1187 if k1 else tmp1198)
tmp1224 = (tmp1225 if depth7 else tmp1188)
tmp1223 = (tmp1224 if depth6 else tmp1188)
tmp1222 = (tmp1185 if depth5 else tmp1223)
tmp1221 = (tmp1222 if depth4 else tmp1200)
tmp1220 = (tmp1199 if depth3 else tmp1221)
tmp1213 = (tmp1214 if depth2 else tmp1220)
tmp1181 = (tmp1182 if depth1 else tmp1213)
tmp1234 = (1 - (1 if action4_1 else tmp1192))
tmp1233 = (tmp1188 if oxygen_full else tmp1234)
tmp1232 = (tmp1233 if depth7 else tmp1188)
tmp1231 = (tmp1232 if depth6 else tmp1188)
tmp1239 = (tmp1233 if k2 else tmp1188)
tmp1238 = (tmp1233 if k1 else tmp1239)
tmp1237 = (tmp1238 if depth7 else tmp1188)
tmp1236 = (tmp1237 if depth6 else tmp1188)
tmp1235 = (tmp1231 if depth5 else tmp1236)
tmp1230 = (tmp1231 if depth4 else tmp1235)
tmp1241 = (tmp1231 if depth5 else tmp1188)
tmp1240 = (tmp1231 if depth4 else tmp1241)
tmp1229 = (tmp1230 if depth3 else tmp1240)
tmp1247 = (tmp1239 if k1 else tmp1188)
tmp1246 = (tmp1247 if depth7 else tmp1188)
tmp1245 = (tmp1246 if depth6 else tmp1188)
tmp1244 = (tmp1231 if depth5 else tmp1245)
tmp1243 = (tmp1231 if depth4 else tmp1244)
tmp1242 = (tmp1243 if depth3 else tmp1240)
tmp1228 = (tmp1229 if depth2 else tmp1242)
tmp1253 = (tmp1239 if depth7 else tmp1188)
tmp1252 = (tmp1253 if depth6 else tmp1188)
tmp1251 = (tmp1231 if depth5 else tmp1252)
tmp1250 = (tmp1231 if depth4 else tmp1251)
tmp1249 = (tmp1250 if depth3 else tmp1240)
tmp1248 = (tmp1249 if depth2 else tmp1240)
tmp1227 = (tmp1228 if depth1 else tmp1248)
tmp1256 = (tmp1231 if depth3 else tmp1240)
tmp1255 = (tmp1256 if depth2 else tmp1249)
tmp1254 = (tmp1255 if depth1 else tmp1228)
tmp1226 = (tmp1227 if s0 else tmp1254)
tmp1180 = (tmp1181 if s1 else tmp1226)
tmp1263 = (tmp1231 if depth3 else tmp1243)
tmp1262 = (tmp1263 if depth2 else tmp1229)
tmp1261 = (tmp1262 if depth1 else tmp1255)
tmp1266 = (tmp1231 if depth3 else tmp1250)
tmp1265 = (tmp1266 if depth2 else tmp1256)
tmp1264 = (tmp1265 if depth1 else tmp1262)
tmp1260 = (tmp1261 if s0 else tmp1264)
tmp1270 = (tmp1231 if depth3 else tmp1230)
tmp1269 = (tmp1270 if depth2 else tmp1263)
tmp1268 = (tmp1269 if depth1 else tmp1265)
tmp1272 = (tmp1231 if depth2 else tmp1266)
tmp1271 = (tmp1272 if depth1 else tmp1269)
tmp1267 = (tmp1268 if s0 else tmp1271)
tmp1259 = (tmp1260 if s1 else tmp1267)
tmp1280 = (tmp1232 if depth6 else tmp1246)
tmp1279 = (tmp1280 if depth5 else tmp1231)
tmp1278 = (tmp1279 if depth4 else tmp1231)
tmp1277 = (tmp1278 if depth3 else tmp1231)
tmp1276 = (tmp1277 if depth2 else tmp1270)
tmp1275 = (tmp1276 if depth1 else tmp1272)
tmp1286 = (tmp1232 if depth6 else tmp1253)
tmp1285 = (tmp1286 if depth5 else tmp1231)
tmp1284 = (tmp1285 if depth4 else tmp1231)
tmp1283 = (tmp1284 if depth3 else tmp1231)
tmp1282 = (tmp1283 if depth2 else tmp1231)
tmp1281 = (tmp1282 if depth1 else tmp1276)
tmp1274 = (tmp1275 if s0 else tmp1281)
tmp1293 = (tmp1232 if depth6 else tmp1237)
tmp1292 = (tmp1293 if depth5 else tmp1231)
tmp1291 = (tmp1292 if depth4 else tmp1231)
tmp1290 = (tmp1291 if depth3 else tmp1231)
tmp1289 = (tmp1290 if depth2 else tmp1277)
tmp1288 = (tmp1289 if depth1 else tmp1282)
tmp1298 = (tmp1232 if depth5 else tmp1231)
tmp1297 = (tmp1298 if depth4 else tmp1231)
tmp1296 = (tmp1297 if depth3 else tmp1231)
tmp1295 = (tmp1296 if depth2 else tmp1283)
tmp1294 = (tmp1295 if depth1 else tmp1289)
tmp1287 = (tmp1288 if s0 else tmp1294)
tmp1273 = (tmp1274 if s1 else tmp1287)
tmp1258 = (tmp1259 if s2 else tmp1273)
tmp1304 = (tmp1297 if depth3 else tmp1278)
tmp1303 = (tmp1304 if depth2 else tmp1290)
tmp1302 = (tmp1303 if depth1 else tmp1295)
tmp1307 = (tmp1297 if depth3 else tmp1284)
tmp1306 = (tmp1307 if depth2 else tmp1296)
tmp1305 = (tmp1306 if depth1 else tmp1303)
tmp1301 = (tmp1302 if s0 else tmp1305)
tmp1311 = (tmp1297 if depth3 else tmp1291)
tmp1310 = (tmp1311 if depth2 else tmp1304)
tmp1309 = (tmp1310 if depth1 else tmp1306)
tmp1313 = (tmp1297 if depth2 else tmp1307)
tmp1312 = (tmp1313 if depth1 else tmp1310)
tmp1308 = (tmp1309 if s0 else tmp1312)
tmp1300 = (tmp1301 if s1 else tmp1308)
tmp1319 = (tmp1298 if depth4 else tmp1279)
tmp1318 = (tmp1319 if depth3 else tmp1297)
tmp1317 = (tmp1318 if depth2 else tmp1311)
tmp1316 = (tmp1317 if depth1 else tmp1313)
tmp1323 = (tmp1298 if depth4 else tmp1285)
tmp1322 = (tmp1323 if depth3 else tmp1297)
tmp1321 = (tmp1322 if depth2 else tmp1297)
tmp1320 = (tmp1321 if depth1 else tmp1317)
tmp1315 = (tmp1316 if s0 else tmp1320)
tmp1328 = (tmp1298 if depth4 else tmp1292)
tmp1327 = (tmp1328 if depth3 else tmp1297)
tmp1326 = (tmp1327 if depth2 else tmp1318)
tmp1325 = (tmp1326 if depth1 else tmp1321)
tmp1331 = (tmp1298 if depth3 else tmp1297)
tmp1330 = (tmp1331 if depth2 else tmp1322)
tmp1329 = (tmp1330 if depth1 else tmp1326)
tmp1324 = (tmp1325 if s0 else tmp1329)
tmp1314 = (tmp1315 if s1 else tmp1324)
tmp1299 = (tmp1300 if s2 else tmp1314)
tmp1257 = (tmp1258 if s3 else tmp1299)
tmp1179 = (tmp1180 if s4 else tmp1257)
tmp1340 = (tmp1298 if depth3 else tmp1319)
tmp1339 = (tmp1340 if depth2 else tmp1327)
tmp1338 = (tmp1339 if depth1 else tmp1330)
tmp1343 = (tmp1298 if depth3 else tmp1323)
tmp1342 = (tmp1343 if depth2 else tmp1331)
tmp1341 = (tmp1342 if depth1 else tmp1339)
tmp1337 = (tmp1338 if s0 else tmp1341)
tmp1347 = (tmp1298 if depth3 else tmp1328)
tmp1346 = (tmp1347 if depth2 else tmp1340)
tmp1345 = (tmp1346 if depth1 else tmp1342)
tmp1349 = (tmp1298 if depth2 else tmp1343)
tmp1348 = (tmp1349 if depth1 else tmp1346)
tmp1344 = (tmp1345 if s0 else tmp1348)
tmp1336 = (tmp1337 if s1 else tmp1344)
tmp1356 = (tmp1232 if depth5 else tmp1280)
tmp1355 = (tmp1356 if depth4 else tmp1298)
tmp1354 = (tmp1355 if depth3 else tmp1298)
tmp1353 = (tmp1354 if depth2 else tmp1347)
tmp1352 = (tmp1353 if depth1 else tmp1349)
tmp1361 = (tmp1232 if depth5 else tmp1286)
tmp1360 = (tmp1361 if depth4 else tmp1298)
tmp1359 = (tmp1360 if depth3 else tmp1298)
tmp1358 = (tmp1359 if depth2 else tmp1298)
tmp1357 = (tmp1358 if depth1 else tmp1353)
tmp1351 = (tmp1352 if s0 else tmp1357)
tmp1367 = (tmp1232 if depth5 else tmp1293)
tmp1366 = (tmp1367 if depth4 else tmp1298)
tmp1365 = (tmp1366 if depth3 else tmp1298)
tmp1364 = (tmp1365 if depth2 else tmp1354)
tmp1363 = (tmp1364 if depth1 else tmp1358)
tmp1371 = (tmp1232 if depth4 else tmp1298)
tmp1370 = (tmp1371 if depth3 else tmp1298)
tmp1369 = (tmp1370 if depth2 else tmp1359)
tmp1368 = (tmp1369 if depth1 else tmp1364)
tmp1362 = (tmp1363 if s0 else tmp1368)
tmp1350 = (tmp1351 if s1 else tmp1362)
tmp1335 = (tmp1336 if s2 else tmp1350)
tmp1377 = (tmp1371 if depth3 else tmp1355)
tmp1376 = (tmp1377 if depth2 else tmp1365)
tmp1375 = (tmp1376 if depth1 else tmp1369)
tmp1380 = (tmp1371 if depth3 else tmp1360)
tmp1379 = (tmp1380 if depth2 else tmp1370)
tmp1378 = (tmp1379 if depth1 else tmp1376)
tmp1374 = (tmp1375 if s0 else tmp1378)
tmp1384 = (tmp1371 if depth3 else tmp1366)
tmp1383 = (tmp1384 if depth2 else tmp1377)
tmp1382 = (tmp1383 if depth1 else tmp1379)
tmp1386 = (tmp1371 if depth2 else tmp1380)
tmp1385 = (tmp1386 if depth1 else tmp1383)
tmp1381 = (tmp1382 if s0 else tmp1385)
tmp1373 = (tmp1374 if s1 else tmp1381)
tmp1392 = (tmp1232 if depth4 else tmp1356)
tmp1391 = (tmp1392 if depth3 else tmp1371)
tmp1390 = (tmp1391 if depth2 else tmp1384)
tmp1389 = (tmp1390 if depth1 else tmp1386)
tmp1396 = (tmp1232 if depth4 else tmp1361)
tmp1395 = (tmp1396 if depth3 else tmp1371)
tmp1394 = (tmp1395 if depth2 else tmp1371)
tmp1393 = (tmp1394 if depth1 else tmp1390)
tmp1388 = (tmp1389 if s0 else tmp1393)
tmp1401 = (tmp1232 if depth4 else tmp1367)
tmp1400 = (tmp1401 if depth3 else tmp1371)
tmp1399 = (tmp1400 if depth2 else tmp1391)
tmp1398 = (tmp1399 if depth1 else tmp1394)
tmp1404 = (tmp1232 if depth3 else tmp1371)
tmp1403 = (tmp1404 if depth2 else tmp1395)
tmp1402 = (tmp1403 if depth1 else tmp1399)
tmp1397 = (tmp1398 if s0 else tmp1402)
tmp1387 = (tmp1388 if s1 else tmp1397)
tmp1372 = (tmp1373 if s2 else tmp1387)
tmp1334 = (tmp1335 if s3 else tmp1372)
tmp1411 = (tmp1232 if depth3 else tmp1392)
tmp1410 = (tmp1411 if depth2 else tmp1400)
tmp1409 = (tmp1410 if depth1 else tmp1403)
tmp1414 = (tmp1232 if depth3 else tmp1396)
tmp1413 = (tmp1414 if depth2 else tmp1404)
tmp1412 = (tmp1413 if depth1 else tmp1410)
tmp1408 = (tmp1409 if s0 else tmp1412)
tmp1418 = (tmp1232 if depth3 else tmp1401)
tmp1417 = (tmp1418 if depth2 else tmp1411)
tmp1416 = (tmp1417 if depth1 else tmp1413)
tmp1420 = (tmp1232 if depth2 else tmp1414)
tmp1419 = (tmp1420 if depth1 else tmp1417)
tmp1415 = (tmp1416 if s0 else tmp1419)
tmp1407 = (tmp1408 if s1 else tmp1415)
tmp1429 = (tmp1233 if depth7 else tmp1247)
tmp1428 = (tmp1429 if depth6 else tmp1232)
tmp1427 = (tmp1428 if depth5 else tmp1232)
tmp1426 = (tmp1427 if depth4 else tmp1232)
tmp1425 = (tmp1426 if depth3 else tmp1232)
tmp1424 = (tmp1425 if depth2 else tmp1418)
tmp1423 = (tmp1424 if depth1 else tmp1420)
tmp1436 = (tmp1233 if depth7 else tmp1239)
tmp1435 = (tmp1436 if depth6 else tmp1232)
tmp1434 = (tmp1435 if depth5 else tmp1232)
tmp1433 = (tmp1434 if depth4 else tmp1232)
tmp1432 = (tmp1433 if depth3 else tmp1232)
tmp1431 = (tmp1432 if depth2 else tmp1232)
tmp1430 = (tmp1431 if depth1 else tmp1424)
tmp1422 = (tmp1423 if s0 else tmp1430)
tmp1444 = (tmp1233 if depth7 else tmp1238)
tmp1443 = (tmp1444 if depth6 else tmp1232)
tmp1442 = (tmp1443 if depth5 else tmp1232)
tmp1441 = (tmp1442 if depth4 else tmp1232)
tmp1440 = (tmp1441 if depth3 else tmp1232)
tmp1439 = (tmp1440 if depth2 else tmp1425)
tmp1438 = (tmp1439 if depth1 else tmp1431)
tmp1450 = (tmp1233 if depth6 else tmp1232)
tmp1449 = (tmp1450 if depth5 else tmp1232)
tmp1448 = (tmp1449 if depth4 else tmp1232)
tmp1447 = (tmp1448 if depth3 else tmp1232)
tmp1446 = (tmp1447 if depth2 else tmp1432)
tmp1445 = (tmp1446 if depth1 else tmp1439)
tmp1437 = (tmp1438 if s0 else tmp1445)
tmp1421 = (tmp1422 if s1 else tmp1437)
tmp1406 = (tmp1407 if s2 else tmp1421)
tmp1456 = (tmp1448 if depth3 else tmp1426)
tmp1455 = (tmp1456 if depth2 else tmp1440)
tmp1454 = (tmp1455 if depth1 else tmp1446)
tmp1459 = (tmp1448 if depth3 else tmp1433)
tmp1458 = (tmp1459 if depth2 else tmp1447)
tmp1457 = (tmp1458 if depth1 else tmp1455)
tmp1453 = (tmp1454 if s0 else tmp1457)
tmp1463 = (tmp1448 if depth3 else tmp1441)
tmp1462 = (tmp1463 if depth2 else tmp1456)
tmp1461 = (tmp1462 if depth1 else tmp1458)
tmp1465 = (tmp1448 if depth2 else tmp1459)
tmp1464 = (tmp1465 if depth1 else tmp1462)
tmp1460 = (tmp1461 if s0 else tmp1464)
tmp1452 = (tmp1453 if s1 else tmp1460)
tmp1471 = (tmp1449 if depth4 else tmp1427)
tmp1470 = (tmp1471 if depth3 else tmp1448)
tmp1469 = (tmp1470 if depth2 else tmp1463)
tmp1468 = (tmp1469 if depth1 else tmp1465)
tmp1475 = (tmp1449 if depth4 else tmp1434)
tmp1474 = (tmp1475 if depth3 else tmp1448)
tmp1473 = (tmp1474 if depth2 else tmp1448)
tmp1472 = (tmp1473 if depth1 else tmp1469)
tmp1467 = (tmp1468 if s0 else tmp1472)
tmp1480 = (tmp1449 if depth4 else tmp1442)
tmp1479 = (tmp1480 if depth3 else tmp1448)
tmp1478 = (tmp1479 if depth2 else tmp1470)
tmp1477 = (tmp1478 if depth1 else tmp1473)
tmp1483 = (tmp1449 if depth3 else tmp1448)
tmp1482 = (tmp1483 if depth2 else tmp1474)
tmp1481 = (tmp1482 if depth1 else tmp1478)
tmp1476 = (tmp1477 if s0 else tmp1481)
tmp1466 = (tmp1467 if s1 else tmp1476)
tmp1451 = (tmp1452 if s2 else tmp1466)
tmp1405 = (tmp1406 if s3 else tmp1451)
tmp1333 = (tmp1334 if s4 else tmp1405)
tmp1491 = (tmp1449 if depth3 else tmp1471)
tmp1490 = (tmp1491 if depth2 else tmp1479)
tmp1489 = (tmp1490 if depth1 else tmp1482)
tmp1494 = (tmp1449 if depth3 else tmp1475)
tmp1493 = (tmp1494 if depth2 else tmp1483)
tmp1492 = (tmp1493 if depth1 else tmp1490)
tmp1488 = (tmp1489 if s0 else tmp1492)
tmp1498 = (tmp1449 if depth3 else tmp1480)
tmp1497 = (tmp1498 if depth2 else tmp1491)
tmp1496 = (tmp1497 if depth1 else tmp1493)
tmp1500 = (tmp1449 if depth2 else tmp1494)
tmp1499 = (tmp1500 if depth1 else tmp1497)
tmp1495 = (tmp1496 if s0 else tmp1499)
tmp1487 = (tmp1488 if s1 else tmp1495)
tmp1507 = (tmp1450 if depth5 else tmp1428)
tmp1506 = (tmp1507 if depth4 else tmp1449)
tmp1505 = (tmp1506 if depth3 else tmp1449)
tmp1504 = (tmp1505 if depth2 else tmp1498)
tmp1503 = (tmp1504 if depth1 else tmp1500)
tmp1512 = (tmp1450 if depth5 else tmp1435)
tmp1511 = (tmp1512 if depth4 else tmp1449)
tmp1510 = (tmp1511 if depth3 else tmp1449)
tmp1509 = (tmp1510 if depth2 else tmp1449)
tmp1508 = (tmp1509 if depth1 else tmp1504)
tmp1502 = (tmp1503 if s0 else tmp1508)
tmp1518 = (tmp1450 if depth5 else tmp1443)
tmp1517 = (tmp1518 if depth4 else tmp1449)
tmp1516 = (tmp1517 if depth3 else tmp1449)
tmp1515 = (tmp1516 if depth2 else tmp1505)
tmp1514 = (tmp1515 if depth1 else tmp1509)
tmp1522 = (tmp1450 if depth4 else tmp1449)
tmp1521 = (tmp1522 if depth3 else tmp1449)
tmp1520 = (tmp1521 if depth2 else tmp1510)
tmp1519 = (tmp1520 if depth1 else tmp1515)
tmp1513 = (tmp1514 if s0 else tmp1519)
tmp1501 = (tmp1502 if s1 else tmp1513)
tmp1486 = (tmp1487 if s2 else tmp1501)
tmp1528 = (tmp1522 if depth3 else tmp1506)
tmp1527 = (tmp1528 if depth2 else tmp1516)
tmp1526 = (tmp1527 if depth1 else tmp1520)
tmp1531 = (tmp1522 if depth3 else tmp1511)
tmp1530 = (tmp1531 if depth2 else tmp1521)
tmp1529 = (tmp1530 if depth1 else tmp1527)
tmp1525 = (tmp1526 if s0 else tmp1529)
tmp1535 = (tmp1522 if depth3 else tmp1517)
tmp1534 = (tmp1535 if depth2 else tmp1528)
tmp1533 = (tmp1534 if depth1 else tmp1530)
tmp1537 = (tmp1522 if depth2 else tmp1531)
tmp1536 = (tmp1537 if depth1 else tmp1534)
tmp1532 = (tmp1533 if s0 else tmp1536)
tmp1524 = (tmp1525 if s1 else tmp1532)
tmp1543 = (tmp1450 if depth4 else tmp1507)
tmp1542 = (tmp1543 if depth3 else tmp1522)
tmp1541 = (tmp1542 if depth2 else tmp1535)
tmp1540 = (tmp1541 if depth1 else tmp1537)
tmp1547 = (tmp1450 if depth4 else tmp1512)
tmp1546 = (tmp1547 if depth3 else tmp1522)
tmp1545 = (tmp1546 if depth2 else tmp1522)
tmp1544 = (tmp1545 if depth1 else tmp1541)
tmp1539 = (tmp1540 if s0 else tmp1544)
tmp1552 = (tmp1450 if depth4 else tmp1518)
tmp1551 = (tmp1552 if depth3 else tmp1522)
tmp1550 = (tmp1551 if depth2 else tmp1542)
tmp1549 = (tmp1550 if depth1 else tmp1545)
tmp1555 = (tmp1450 if depth3 else tmp1522)
tmp1554 = (tmp1555 if depth2 else tmp1546)
tmp1553 = (tmp1554 if depth1 else tmp1550)
tmp1548 = (tmp1549 if s0 else tmp1553)
tmp1538 = (tmp1539 if s1 else tmp1548)
tmp1523 = (tmp1524 if s2 else tmp1538)
tmp1485 = (tmp1486 if s3 else tmp1523)
tmp1562 = (tmp1450 if depth3 else tmp1543)
tmp1561 = (tmp1562 if depth2 else tmp1551)
tmp1560 = (tmp1561 if depth1 else tmp1554)
tmp1565 = (tmp1450 if depth3 else tmp1547)
tmp1564 = (tmp1565 if depth2 else tmp1555)
tmp1563 = (tmp1564 if depth1 else tmp1561)
tmp1559 = (tmp1560 if s0 else tmp1563)
tmp1569 = (tmp1450 if depth3 else tmp1552)
tmp1568 = (tmp1569 if depth2 else tmp1562)
tmp1567 = (tmp1568 if depth1 else tmp1564)
tmp1571 = (tmp1450 if depth2 else tmp1565)
tmp1570 = (tmp1571 if depth1 else tmp1568)
tmp1566 = (tmp1567 if s0 else tmp1570)
tmp1558 = (tmp1559 if s1 else tmp1566)
tmp1579 = (tmp1233 if depth6 else tmp1429)
tmp1578 = (tmp1579 if depth5 else tmp1450)
tmp1577 = (tmp1578 if depth4 else tmp1450)
tmp1576 = (tmp1577 if depth3 else tmp1450)
tmp1575 = (tmp1576 if depth2 else tmp1569)
tmp1574 = (tmp1575 if depth1 else tmp1571)
tmp1585 = (tmp1233 if depth6 else tmp1436)
tmp1584 = (tmp1585 if depth5 else tmp1450)
tmp1583 = (tmp1584 if depth4 else tmp1450)
tmp1582 = (tmp1583 if depth3 else tmp1450)
tmp1581 = (tmp1582 if depth2 else tmp1450)
tmp1580 = (tmp1581 if depth1 else tmp1575)
tmp1573 = (tmp1574 if s0 else tmp1580)
tmp1592 = (tmp1233 if depth6 else tmp1444)
tmp1591 = (tmp1592 if depth5 else tmp1450)
tmp1590 = (tmp1591 if depth4 else tmp1450)
tmp1589 = (tmp1590 if depth3 else tmp1450)
tmp1588 = (tmp1589 if depth2 else tmp1576)
tmp1587 = (tmp1588 if depth1 else tmp1581)
tmp1597 = (tmp1233 if depth5 else tmp1450)
tmp1596 = (tmp1597 if depth4 else tmp1450)
tmp1595 = (tmp1596 if depth3 else tmp1450)
tmp1594 = (tmp1595 if depth2 else tmp1582)
tmp1593 = (tmp1594 if depth1 else tmp1588)
tmp1586 = (tmp1587 if s0 else tmp1593)
tmp1572 = (tmp1573 if s1 else tmp1586)
tmp1557 = (tmp1558 if s2 else tmp1572)
tmp1603 = (tmp1596 if depth3 else tmp1577)
tmp1602 = (tmp1603 if depth2 else tmp1589)
tmp1601 = (tmp1602 if depth1 else tmp1594)
tmp1606 = (tmp1596 if depth3 else tmp1583)
tmp1605 = (tmp1606 if depth2 else tmp1595)
tmp1604 = (tmp1605 if depth1 else tmp1602)
tmp1600 = (tmp1601 if s0 else tmp1604)
tmp1610 = (tmp1596 if depth3 else tmp1590)
tmp1609 = (tmp1610 if depth2 else tmp1603)
tmp1608 = (tmp1609 if depth1 else tmp1605)
tmp1612 = (tmp1596 if depth2 else tmp1606)
tmp1611 = (tmp1612 if depth1 else tmp1609)
tmp1607 = (tmp1608 if s0 else tmp1611)
tmp1599 = (tmp1600 if s1 else tmp1607)
tmp1618 = (tmp1597 if depth4 else tmp1578)
tmp1617 = (tmp1618 if depth3 else tmp1596)
tmp1616 = (tmp1617 if depth2 else tmp1610)
tmp1615 = (tmp1616 if depth1 else tmp1612)
tmp1622 = (tmp1597 if depth4 else tmp1584)
tmp1621 = (tmp1622 if depth3 else tmp1596)
tmp1620 = (tmp1621 if depth2 else tmp1596)
tmp1619 = (tmp1620 if depth1 else tmp1616)
tmp1614 = (tmp1615 if s0 else tmp1619)
tmp1627 = (tmp1597 if depth4 else tmp1591)
tmp1626 = (tmp1627 if depth3 else tmp1596)
tmp1625 = (tmp1626 if depth2 else tmp1617)
tmp1624 = (tmp1625 if depth1 else tmp1620)
tmp1630 = (tmp1597 if depth3 else tmp1596)
tmp1629 = (tmp1630 if depth2 else tmp1621)
tmp1628 = (tmp1629 if depth1 else tmp1625)
tmp1623 = (tmp1624 if s0 else tmp1628)
tmp1613 = (tmp1614 if s1 else tmp1623)
tmp1598 = (tmp1599 if s2 else tmp1613)
tmp1556 = (tmp1557 if s3 else tmp1598)
tmp1484 = (tmp1485 if s4 else tmp1556)
tmp1332 = (tmp1333 if s5 else tmp1484)
tmp1178 = (tmp1179 if s6 else tmp1332)
tmp1640 = (tmp1597 if depth3 else tmp1618)
tmp1639 = (tmp1640 if depth2 else tmp1626)
tmp1638 = (tmp1639 if depth1 else tmp1629)
tmp1643 = (tmp1597 if depth3 else tmp1622)
tmp1642 = (tmp1643 if depth2 else tmp1630)
tmp1641 = (tmp1642 if depth1 else tmp1639)
tmp1637 = (tmp1638 if s0 else tmp1641)
tmp1647 = (tmp1597 if depth3 else tmp1627)
tmp1646 = (tmp1647 if depth2 else tmp1640)
tmp1645 = (tmp1646 if depth1 else tmp1642)
tmp1649 = (tmp1597 if depth2 else tmp1643)
tmp1648 = (tmp1649 if depth1 else tmp1646)
tmp1644 = (tmp1645 if s0 else tmp1648)
tmp1636 = (tmp1637 if s1 else tmp1644)
tmp1656 = (tmp1233 if depth5 else tmp1579)
tmp1655 = (tmp1656 if depth4 else tmp1597)
tmp1654 = (tmp1655 if depth3 else tmp1597)
tmp1653 = (tmp1654 if depth2 else tmp1647)
tmp1652 = (tmp1653 if depth1 else tmp1649)
tmp1661 = (tmp1233 if depth5 else tmp1585)
tmp1660 = (tmp1661 if depth4 else tmp1597)
tmp1659 = (tmp1660 if depth3 else tmp1597)
tmp1658 = (tmp1659 if depth2 else tmp1597)
tmp1657 = (tmp1658 if depth1 else tmp1653)
tmp1651 = (tmp1652 if s0 else tmp1657)
tmp1667 = (tmp1233 if depth5 else tmp1592)
tmp1666 = (tmp1667 if depth4 else tmp1597)
tmp1665 = (tmp1666 if depth3 else tmp1597)
tmp1664 = (tmp1665 if depth2 else tmp1654)
tmp1663 = (tmp1664 if depth1 else tmp1658)
tmp1671 = (tmp1233 if depth4 else tmp1597)
tmp1670 = (tmp1671 if depth3 else tmp1597)
tmp1669 = (tmp1670 if depth2 else tmp1659)
tmp1668 = (tmp1669 if depth1 else tmp1664)
tmp1662 = (tmp1663 if s0 else tmp1668)
tmp1650 = (tmp1651 if s1 else tmp1662)
tmp1635 = (tmp1636 if s2 else tmp1650)
tmp1677 = (tmp1671 if depth3 else tmp1655)
tmp1676 = (tmp1677 if depth2 else tmp1665)
tmp1675 = (tmp1676 if depth1 else tmp1669)
tmp1680 = (tmp1671 if depth3 else tmp1660)
tmp1679 = (tmp1680 if depth2 else tmp1670)
tmp1678 = (tmp1679 if depth1 else tmp1676)
tmp1674 = (tmp1675 if s0 else tmp1678)
tmp1684 = (tmp1671 if depth3 else tmp1666)
tmp1683 = (tmp1684 if depth2 else tmp1677)
tmp1682 = (tmp1683 if depth1 else tmp1679)
tmp1686 = (tmp1671 if depth2 else tmp1680)
tmp1685 = (tmp1686 if depth1 else tmp1683)
tmp1681 = (tmp1682 if s0 else tmp1685)
tmp1673 = (tmp1674 if s1 else tmp1681)
tmp1692 = (tmp1233 if depth4 else tmp1656)
tmp1691 = (tmp1692 if depth3 else tmp1671)
tmp1690 = (tmp1691 if depth2 else tmp1684)
tmp1689 = (tmp1690 if depth1 else tmp1686)
tmp1696 = (tmp1233 if depth4 else tmp1661)
tmp1695 = (tmp1696 if depth3 else tmp1671)
tmp1694 = (tmp1695 if depth2 else tmp1671)
tmp1693 = (tmp1694 if depth1 else tmp1690)
tmp1688 = (tmp1689 if s0 else tmp1693)
tmp1701 = (tmp1233 if depth4 else tmp1667)
tmp1700 = (tmp1701 if depth3 else tmp1671)
tmp1699 = (tmp1700 if depth2 else tmp1691)
tmp1698 = (tmp1699 if depth1 else tmp1694)
tmp1704 = (tmp1233 if depth3 else tmp1671)
tmp1703 = (tmp1704 if depth2 else tmp1695)
tmp1702 = (tmp1703 if depth1 else tmp1699)
tmp1697 = (tmp1698 if s0 else tmp1702)
tmp1687 = (tmp1688 if s1 else tmp1697)
tmp1672 = (tmp1673 if s2 else tmp1687)
tmp1634 = (tmp1635 if s3 else tmp1672)
tmp1711 = (tmp1233 if depth3 else tmp1692)
tmp1710 = (tmp1711 if depth2 else tmp1700)
tmp1709 = (tmp1710 if depth1 else tmp1703)
tmp1714 = (tmp1233 if depth3 else tmp1696)
tmp1713 = (tmp1714 if depth2 else tmp1704)
tmp1712 = (tmp1713 if depth1 else tmp1710)
tmp1708 = (tmp1709 if s0 else tmp1712)
tmp1718 = (tmp1233 if depth3 else tmp1701)
tmp1717 = (tmp1718 if depth2 else tmp1711)
tmp1716 = (tmp1717 if depth1 else tmp1713)
tmp1720 = (tmp1233 if depth2 else tmp1714)
tmp1719 = (tmp1720 if depth1 else tmp1717)
tmp1715 = (tmp1716 if s0 else tmp1719)
tmp1707 = (tmp1708 if s1 else tmp1715)
tmp1724 = (tmp1233 if depth2 else tmp1718)
tmp1723 = (tmp1724 if depth1 else tmp1720)
tmp1725 = (tmp1233 if depth1 else tmp1724)
tmp1722 = (tmp1723 if s0 else tmp1725)
tmp1721 = (tmp1722 if s1 else tmp1181)
tmp1706 = (tmp1707 if s2 else tmp1721)
tmp1727 = (tmp1226 if s1 else tmp1260)
tmp1728 = (tmp1267 if s1 else tmp1274)
tmp1726 = (tmp1727 if s2 else tmp1728)
tmp1705 = (tmp1706 if s3 else tmp1726)
tmp1633 = (tmp1634 if s4 else tmp1705)
tmp1732 = (tmp1287 if s1 else tmp1301)
tmp1733 = (tmp1308 if s1 else tmp1315)
tmp1731 = (tmp1732 if s2 else tmp1733)
tmp1735 = (tmp1324 if s1 else tmp1337)
tmp1736 = (tmp1344 if s1 else tmp1351)
tmp1734 = (tmp1735 if s2 else tmp1736)
tmp1730 = (tmp1731 if s3 else tmp1734)
tmp1739 = (tmp1362 if s1 else tmp1374)
tmp1740 = (tmp1381 if s1 else tmp1388)
tmp1738 = (tmp1739 if s2 else tmp1740)
tmp1742 = (tmp1397 if s1 else tmp1408)
tmp1743 = (tmp1415 if s1 else tmp1422)
tmp1741 = (tmp1742 if s2 else tmp1743)
tmp1737 = (tmp1738 if s3 else tmp1741)
tmp1729 = (tmp1730 if s4 else tmp1737)
tmp1632 = (tmp1633 if s5 else tmp1729)
tmp1748 = (tmp1437 if s1 else tmp1453)
tmp1749 = (tmp1460 if s1 else tmp1467)
tmp1747 = (tmp1748 if s2 else tmp1749)
tmp1751 = (tmp1476 if s1 else tmp1488)
tmp1752 = (tmp1495 if s1 else tmp1502)
tmp1750 = (tmp1751 if s2 else tmp1752)
tmp1746 = (tmp1747 if s3 else tmp1750)
tmp1755 = (tmp1513 if s1 else tmp1525)
tmp1756 = (tmp1532 if s1 else tmp1539)
tmp1754 = (tmp1755 if s2 else tmp1756)
tmp1758 = (tmp1548 if s1 else tmp1559)
tmp1759 = (tmp1566 if s1 else tmp1573)
tmp1757 = (tmp1758 if s2 else tmp1759)
tmp1753 = (tmp1754 if s3 else tmp1757)
tmp1745 = (tmp1746 if s4 else tmp1753)
tmp1763 = (tmp1586 if s1 else tmp1600)
tmp1764 = (tmp1607 if s1 else tmp1614)
tmp1762 = (tmp1763 if s2 else tmp1764)
tmp1766 = (tmp1623 if s1 else tmp1637)
tmp1767 = (tmp1644 if s1 else tmp1651)
tmp1765 = (tmp1766 if s2 else tmp1767)
tmp1761 = (tmp1762 if s3 else tmp1765)
tmp1770 = (tmp1662 if s1 else tmp1674)
tmp1771 = (tmp1681 if s1 else tmp1688)
tmp1769 = (tmp1770 if s2 else tmp1771)
tmp1773 = (tmp1697 if s1 else tmp1708)
tmp1774 = (tmp1715 if s1 else tmp1722)
tmp1772 = (tmp1773 if s2 else tmp1774)
tmp1768 = (tmp1769 if s3 else tmp1772)
tmp1760 = (tmp1761 if s4 else tmp1768)
tmp1744 = (tmp1745 if s5 else tmp1760)
tmp1631 = (tmp1632 if s6 else tmp1744)
tmp1177 = (1 - (tmp1178 if s7 else tmp1631))
action3__s = tmp1177
tmp1786 = (1 if action4_1 else 0)
tmp1788 = (1 - (1 if action4_1 else 0))
tmp1787 = (1 - (1 if oxygen_low else tmp1788))
tmp1785 = (tmp1786 if oxygen_full else tmp1787)
tmp1784 = (tmp1785 if depth7 else tmp1786)
tmp1783 = (tmp1784 if depth6 else tmp1786)
tmp1792 = (tmp1785 if k2 else tmp1786)
tmp1791 = (tmp1792 if depth7 else tmp1786)
tmp1790 = (tmp1791 if depth6 else tmp1786)
tmp1789 = (tmp1783 if depth5 else tmp1790)
tmp1782 = (tmp1783 if depth4 else tmp1789)
tmp1794 = (tmp1783 if depth5 else tmp1786)
tmp1793 = (tmp1783 if depth4 else tmp1794)
tmp1781 = (tmp1782 if depth3 else tmp1793)
tmp1780 = (tmp1781 if depth2 else tmp1793)
tmp1801 = (tmp1792 if k1 else tmp1786)
tmp1800 = (tmp1801 if depth7 else tmp1786)
tmp1799 = (tmp1800 if depth6 else tmp1786)
tmp1798 = (tmp1783 if depth5 else tmp1799)
tmp1797 = (tmp1783 if depth4 else tmp1798)
tmp1796 = (tmp1797 if depth3 else tmp1793)
tmp1807 = (tmp1785 if k1 else tmp1792)
tmp1806 = (tmp1807 if depth7 else tmp1786)
tmp1805 = (tmp1806 if depth6 else tmp1786)
tmp1804 = (tmp1783 if depth5 else tmp1805)
tmp1803 = (tmp1804 if depth4 else tmp1794)
tmp1802 = (tmp1793 if depth3 else tmp1803)
tmp1795 = (tmp1796 if depth2 else tmp1802)
tmp1779 = (tmp1780 if depth1 else tmp1795)
tmp1815 = (tmp1786 if oxygen_full else 0)
tmp1814 = (tmp1815 if depth7 else tmp1786)
tmp1813 = (tmp1814 if depth6 else tmp1786)
tmp1820 = (tmp1815 if k2 else tmp1786)
tmp1819 = (tmp1815 if k1 else tmp1820)
tmp1818 = (tmp1819 if depth7 else tmp1786)
tmp1817 = (tmp1818 if depth6 else tmp1786)
tmp1816 = (tmp1813 if depth5 else tmp1817)
tmp1812 = (tmp1813 if depth4 else tmp1816)
tmp1822 = (tmp1813 if depth5 else tmp1786)
tmp1821 = (tmp1813 if depth4 else tmp1822)
tmp1811 = (tmp1812 if depth3 else tmp1821)
tmp1828 = (tmp1820 if k1 else tmp1786)
tmp1827 = (tmp1828 if depth7 else tmp1786)
tmp1826 = (tmp1827 if depth6 else tmp1786)
tmp1825 = (tmp1813 if depth5 else tmp1826)
tmp1824 = (tmp1813 if depth4 else tmp1825)
tmp1823 = (tmp1824 if depth3 else tmp1821)
tmp1810 = (tmp1811 if depth2 else tmp1823)
tmp1834 = (tmp1820 if depth7 else tmp1786)
tmp1833 = (tmp1834 if depth6 else tmp1786)
tmp1832 = (tmp1813 if depth5 else tmp1833)
tmp1831 = (tmp1813 if depth4 else tmp1832)
tmp1830 = (tmp1831 if depth3 else tmp1821)
tmp1829 = (tmp1830 if depth2 else tmp1821)
tmp1809 = (tmp1810 if depth1 else tmp1829)
tmp1837 = (tmp1813 if depth3 else tmp1821)
tmp1836 = (tmp1837 if depth2 else tmp1830)
tmp1835 = (tmp1836 if depth1 else tmp1810)
tmp1808 = (tmp1809 if s0 else tmp1835)
tmp1778 = (tmp1779 if s1 else tmp1808)
tmp1844 = (tmp1813 if depth3 else tmp1824)
tmp1843 = (tmp1844 if depth2 else tmp1811)
tmp1842 = (tmp1843 if depth1 else tmp1836)
tmp1847 = (tmp1813 if depth3 else tmp1831)
tmp1846 = (tmp1847 if depth2 else tmp1837)
tmp1845 = (tmp1846 if depth1 else tmp1843)
tmp1841 = (tmp1842 if s0 else tmp1845)
tmp1851 = (tmp1813 if depth3 else tmp1812)
tmp1850 = (tmp1851 if depth2 else tmp1844)
tmp1849 = (tmp1850 if depth1 else tmp1846)
tmp1853 = (tmp1813 if depth2 else tmp1847)
tmp1852 = (tmp1853 if depth1 else tmp1850)
tmp1848 = (tmp1849 if s0 else tmp1852)
tmp1840 = (tmp1841 if s1 else tmp1848)
tmp1861 = (tmp1814 if depth6 else tmp1827)
tmp1860 = (tmp1861 if depth5 else tmp1813)
tmp1859 = (tmp1860 if depth4 else tmp1813)
tmp1858 = (tmp1859 if depth3 else tmp1813)
tmp1857 = (tmp1858 if depth2 else tmp1851)
tmp1856 = (tmp1857 if depth1 else tmp1853)
tmp1867 = (tmp1814 if depth6 else tmp1834)
tmp1866 = (tmp1867 if depth5 else tmp1813)
tmp1865 = (tmp1866 if depth4 else tmp1813)
tmp1864 = (tmp1865 if depth3 else tmp1813)
tmp1863 = (tmp1864 if depth2 else tmp1813)
tmp1862 = (tmp1863 if depth1 else tmp1857)
tmp1855 = (tmp1856 if s0 else tmp1862)
tmp1874 = (tmp1814 if depth6 else tmp1818)
tmp1873 = (tmp1874 if depth5 else tmp1813)
tmp1872 = (tmp1873 if depth4 else tmp1813)
tmp1871 = (tmp1872 if depth3 else tmp1813)
tmp1870 = (tmp1871 if depth2 else tmp1858)
tmp1869 = (tmp1870 if depth1 else tmp1863)
tmp1879 = (tmp1814 if depth5 else tmp1813)
tmp1878 = (tmp1879 if depth4 else tmp1813)
tmp1877 = (tmp1878 if depth3 else tmp1813)
tmp1876 = (tmp1877 if depth2 else tmp1864)
tmp1875 = (tmp1876 if depth1 else tmp1870)
tmp1868 = (tmp1869 if s0 else tmp1875)
tmp1854 = (tmp1855 if s1 else tmp1868)
tmp1839 = (tmp1840 if s2 else tmp1854)
tmp1885 = (tmp1878 if depth3 else tmp1859)
tmp1884 = (tmp1885 if depth2 else tmp1871)
tmp1883 = (tmp1884 if depth1 else tmp1876)
tmp1888 = (tmp1878 if depth3 else tmp1865)
tmp1887 = (tmp1888 if depth2 else tmp1877)
tmp1886 = (tmp1887 if depth1 else tmp1884)
tmp1882 = (tmp1883 if s0 else tmp1886)
tmp1892 = (tmp1878 if depth3 else tmp1872)
tmp1891 = (tmp1892 if depth2 else tmp1885)
tmp1890 = (tmp1891 if depth1 else tmp1887)
tmp1894 = (tmp1878 if depth2 else tmp1888)
tmp1893 = (tmp1894 if depth1 else tmp1891)
tmp1889 = (tmp1890 if s0 else tmp1893)
tmp1881 = (tmp1882 if s1 else tmp1889)
tmp1900 = (tmp1879 if depth4 else tmp1860)
tmp1899 = (tmp1900 if depth3 else tmp1878)
tmp1898 = (tmp1899 if depth2 else tmp1892)
tmp1897 = (tmp1898 if depth1 else tmp1894)
tmp1904 = (tmp1879 if depth4 else tmp1866)
tmp1903 = (tmp1904 if depth3 else tmp1878)
tmp1902 = (tmp1903 if depth2 else tmp1878)
tmp1901 = (tmp1902 if depth1 else tmp1898)
tmp1896 = (tmp1897 if s0 else tmp1901)
tmp1909 = (tmp1879 if depth4 else tmp1873)
tmp1908 = (tmp1909 if depth3 else tmp1878)
tmp1907 = (tmp1908 if depth2 else tmp1899)
tmp1906 = (tmp1907 if depth1 else tmp1902)
tmp1912 = (tmp1879 if depth3 else tmp1878)
tmp1911 = (tmp1912 if depth2 else tmp1903)
tmp1910 = (tmp1911 if depth1 else tmp1907)
tmp1905 = (tmp1906 if s0 else tmp1910)
tmp1895 = (tmp1896 if s1 else tmp1905)
tmp1880 = (tmp1881 if s2 else tmp1895)
tmp1838 = (tmp1839 if s3 else tmp1880)
tmp1777 = (tmp1778 if s4 else tmp1838)
tmp1921 = (tmp1879 if depth3 else tmp1900)
tmp1920 = (tmp1921 if depth2 else tmp1908)
tmp1919 = (tmp1920 if depth1 else tmp1911)
tmp1924 = (tmp1879 if depth3 else tmp1904)
tmp1923 = (tmp1924 if depth2 else tmp1912)
tmp1922 = (tmp1923 if depth1 else tmp1920)
tmp1918 = (tmp1919 if s0 else tmp1922)
tmp1928 = (tmp1879 if depth3 else tmp1909)
tmp1927 = (tmp1928 if depth2 else tmp1921)
tmp1926 = (tmp1927 if depth1 else tmp1923)
tmp1930 = (tmp1879 if depth2 else tmp1924)
tmp1929 = (tmp1930 if depth1 else tmp1927)
tmp1925 = (tmp1926 if s0 else tmp1929)
tmp1917 = (tmp1918 if s1 else tmp1925)
tmp1937 = (tmp1814 if depth5 else tmp1861)
tmp1936 = (tmp1937 if depth4 else tmp1879)
tmp1935 = (tmp1936 if depth3 else tmp1879)
tmp1934 = (tmp1935 if depth2 else tmp1928)
tmp1933 = (tmp1934 if depth1 else tmp1930)
tmp1942 = (tmp1814 if depth5 else tmp1867)
tmp1941 = (tmp1942 if depth4 else tmp1879)
tmp1940 = (tmp1941 if depth3 else tmp1879)
tmp1939 = (tmp1940 if depth2 else tmp1879)
tmp1938 = (tmp1939 if depth1 else tmp1934)
tmp1932 = (tmp1933 if s0 else tmp1938)
tmp1948 = (tmp1814 if depth5 else tmp1874)
tmp1947 = (tmp1948 if depth4 else tmp1879)
tmp1946 = (tmp1947 if depth3 else tmp1879)
tmp1945 = (tmp1946 if depth2 else tmp1935)
tmp1944 = (tmp1945 if depth1 else tmp1939)
tmp1952 = (tmp1814 if depth4 else tmp1879)
tmp1951 = (tmp1952 if depth3 else tmp1879)
tmp1950 = (tmp1951 if depth2 else tmp1940)
tmp1949 = (tmp1950 if depth1 else tmp1945)
tmp1943 = (tmp1944 if s0 else tmp1949)
tmp1931 = (tmp1932 if s1 else tmp1943)
tmp1916 = (tmp1917 if s2 else tmp1931)
tmp1958 = (tmp1952 if depth3 else tmp1936)
tmp1957 = (tmp1958 if depth2 else tmp1946)
tmp1956 = (tmp1957 if depth1 else tmp1950)
tmp1961 = (tmp1952 if depth3 else tmp1941)
tmp1960 = (tmp1961 if depth2 else tmp1951)
tmp1959 = (tmp1960 if depth1 else tmp1957)
tmp1955 = (tmp1956 if s0 else tmp1959)
tmp1965 = (tmp1952 if depth3 else tmp1947)
tmp1964 = (tmp1965 if depth2 else tmp1958)
tmp1963 = (tmp1964 if depth1 else tmp1960)
tmp1967 = (tmp1952 if depth2 else tmp1961)
tmp1966 = (tmp1967 if depth1 else tmp1964)
tmp1962 = (tmp1963 if s0 else tmp1966)
tmp1954 = (tmp1955 if s1 else tmp1962)
tmp1973 = (tmp1814 if depth4 else tmp1937)
tmp1972 = (tmp1973 if depth3 else tmp1952)
tmp1971 = (tmp1972 if depth2 else tmp1965)
tmp1970 = (tmp1971 if depth1 else tmp1967)
tmp1977 = (tmp1814 if depth4 else tmp1942)
tmp1976 = (tmp1977 if depth3 else tmp1952)
tmp1975 = (tmp1976 if depth2 else tmp1952)
tmp1974 = (tmp1975 if depth1 else tmp1971)
tmp1969 = (tmp1970 if s0 else tmp1974)
tmp1982 = (tmp1814 if depth4 else tmp1948)
tmp1981 = (tmp1982 if depth3 else tmp1952)
tmp1980 = (tmp1981 if depth2 else tmp1972)
tmp1979 = (tmp1980 if depth1 else tmp1975)
tmp1985 = (tmp1814 if depth3 else tmp1952)
tmp1984 = (tmp1985 if depth2 else tmp1976)
tmp1983 = (tmp1984 if depth1 else tmp1980)
tmp1978 = (tmp1979 if s0 else tmp1983)
tmp1968 = (tmp1969 if s1 else tmp1978)
tmp1953 = (tmp1954 if s2 else tmp1968)
tmp1915 = (tmp1916 if s3 else tmp1953)
tmp1992 = (tmp1814 if depth3 else tmp1973)
tmp1991 = (tmp1992 if depth2 else tmp1981)
tmp1990 = (tmp1991 if depth1 else tmp1984)
tmp1995 = (tmp1814 if depth3 else tmp1977)
tmp1994 = (tmp1995 if depth2 else tmp1985)
tmp1993 = (tmp1994 if depth1 else tmp1991)
tmp1989 = (tmp1990 if s0 else tmp1993)
tmp1999 = (tmp1814 if depth3 else tmp1982)
tmp1998 = (tmp1999 if depth2 else tmp1992)
tmp1997 = (tmp1998 if depth1 else tmp1994)
tmp2001 = (tmp1814 if depth2 else tmp1995)
tmp2000 = (tmp2001 if depth1 else tmp1998)
tmp1996 = (tmp1997 if s0 else tmp2000)
tmp1988 = (tmp1989 if s1 else tmp1996)
tmp2010 = (tmp1815 if depth7 else tmp1828)
tmp2009 = (tmp2010 if depth6 else tmp1814)
tmp2008 = (tmp2009 if depth5 else tmp1814)
tmp2007 = (tmp2008 if depth4 else tmp1814)
tmp2006 = (tmp2007 if depth3 else tmp1814)
tmp2005 = (tmp2006 if depth2 else tmp1999)
tmp2004 = (tmp2005 if depth1 else tmp2001)
tmp2017 = (tmp1815 if depth7 else tmp1820)
tmp2016 = (tmp2017 if depth6 else tmp1814)
tmp2015 = (tmp2016 if depth5 else tmp1814)
tmp2014 = (tmp2015 if depth4 else tmp1814)
tmp2013 = (tmp2014 if depth3 else tmp1814)
tmp2012 = (tmp2013 if depth2 else tmp1814)
tmp2011 = (tmp2012 if depth1 else tmp2005)
tmp2003 = (tmp2004 if s0 else tmp2011)
tmp2025 = (tmp1815 if depth7 else tmp1819)
tmp2024 = (tmp2025 if depth6 else tmp1814)
tmp2023 = (tmp2024 if depth5 else tmp1814)
tmp2022 = (tmp2023 if depth4 else tmp1814)
tmp2021 = (tmp2022 if depth3 else tmp1814)
tmp2020 = (tmp2021 if depth2 else tmp2006)
tmp2019 = (tmp2020 if depth1 else tmp2012)
tmp2031 = (tmp1815 if depth6 else tmp1814)
tmp2030 = (tmp2031 if depth5 else tmp1814)
tmp2029 = (tmp2030 if depth4 else tmp1814)
tmp2028 = (tmp2029 if depth3 else tmp1814)
tmp2027 = (tmp2028 if depth2 else tmp2013)
tmp2026 = (tmp2027 if depth1 else tmp2020)
tmp2018 = (tmp2019 if s0 else tmp2026)
tmp2002 = (tmp2003 if s1 else tmp2018)
tmp1987 = (tmp1988 if s2 else tmp2002)
tmp2037 = (tmp2029 if depth3 else tmp2007)
tmp2036 = (tmp2037 if depth2 else tmp2021)
tmp2035 = (tmp2036 if depth1 else tmp2027)
tmp2040 = (tmp2029 if depth3 else tmp2014)
tmp2039 = (tmp2040 if depth2 else tmp2028)
tmp2038 = (tmp2039 if depth1 else tmp2036)
tmp2034 = (tmp2035 if s0 else tmp2038)
tmp2044 = (tmp2029 if depth3 else tmp2022)
tmp2043 = (tmp2044 if depth2 else tmp2037)
tmp2042 = (tmp2043 if depth1 else tmp2039)
tmp2046 = (tmp2029 if depth2 else tmp2040)
tmp2045 = (tmp2046 if depth1 else tmp2043)
tmp2041 = (tmp2042 if s0 else tmp2045)
tmp2033 = (tmp2034 if s1 else tmp2041)
tmp2052 = (tmp2030 if depth4 else tmp2008)
tmp2051 = (tmp2052 if depth3 else tmp2029)
tmp2050 = (tmp2051 if depth2 else tmp2044)
tmp2049 = (tmp2050 if depth1 else tmp2046)
tmp2056 = (tmp2030 if depth4 else tmp2015)
tmp2055 = (tmp2056 if depth3 else tmp2029)
tmp2054 = (tmp2055 if depth2 else tmp2029)
tmp2053 = (tmp2054 if depth1 else tmp2050)
tmp2048 = (tmp2049 if s0 else tmp2053)
tmp2061 = (tmp2030 if depth4 else tmp2023)
tmp2060 = (tmp2061 if depth3 else tmp2029)
tmp2059 = (tmp2060 if depth2 else tmp2051)
tmp2058 = (tmp2059 if depth1 else tmp2054)
tmp2064 = (tmp2030 if depth3 else tmp2029)
tmp2063 = (tmp2064 if depth2 else tmp2055)
tmp2062 = (tmp2063 if depth1 else tmp2059)
tmp2057 = (tmp2058 if s0 else tmp2062)
tmp2047 = (tmp2048 if s1 else tmp2057)
tmp2032 = (tmp2033 if s2 else tmp2047)
tmp1986 = (tmp1987 if s3 else tmp2032)
tmp1914 = (tmp1915 if s4 else tmp1986)
tmp2072 = (tmp2030 if depth3 else tmp2052)
tmp2071 = (tmp2072 if depth2 else tmp2060)
tmp2070 = (tmp2071 if depth1 else tmp2063)
tmp2075 = (tmp2030 if depth3 else tmp2056)
tmp2074 = (tmp2075 if depth2 else tmp2064)
tmp2073 = (tmp2074 if depth1 else tmp2071)
tmp2069 = (tmp2070 if s0 else tmp2073)
tmp2079 = (tmp2030 if depth3 else tmp2061)
tmp2078 = (tmp2079 if depth2 else tmp2072)
tmp2077 = (tmp2078 if depth1 else tmp2074)
tmp2081 = (tmp2030 if depth2 else tmp2075)
tmp2080 = (tmp2081 if depth1 else tmp2078)
tmp2076 = (tmp2077 if s0 else tmp2080)
tmp2068 = (tmp2069 if s1 else tmp2076)
tmp2088 = (tmp2031 if depth5 else tmp2009)
tmp2087 = (tmp2088 if depth4 else tmp2030)
tmp2086 = (tmp2087 if depth3 else tmp2030)
tmp2085 = (tmp2086 if depth2 else tmp2079)
tmp2084 = (tmp2085 if depth1 else tmp2081)
tmp2093 = (tmp2031 if depth5 else tmp2016)
tmp2092 = (tmp2093 if depth4 else tmp2030)
tmp2091 = (tmp2092 if depth3 else tmp2030)
tmp2090 = (tmp2091 if depth2 else tmp2030)
tmp2089 = (tmp2090 if depth1 else tmp2085)
tmp2083 = (tmp2084 if s0 else tmp2089)
tmp2099 = (tmp2031 if depth5 else tmp2024)
tmp2098 = (tmp2099 if depth4 else tmp2030)
tmp2097 = (tmp2098 if depth3 else tmp2030)
tmp2096 = (tmp2097 if depth2 else tmp2086)
tmp2095 = (tmp2096 if depth1 else tmp2090)
tmp2103 = (tmp2031 if depth4 else tmp2030)
tmp2102 = (tmp2103 if depth3 else tmp2030)
tmp2101 = (tmp2102 if depth2 else tmp2091)
tmp2100 = (tmp2101 if depth1 else tmp2096)
tmp2094 = (tmp2095 if s0 else tmp2100)
tmp2082 = (tmp2083 if s1 else tmp2094)
tmp2067 = (tmp2068 if s2 else tmp2082)
tmp2109 = (tmp2103 if depth3 else tmp2087)
tmp2108 = (tmp2109 if depth2 else tmp2097)
tmp2107 = (tmp2108 if depth1 else tmp2101)
tmp2112 = (tmp2103 if depth3 else tmp2092)
tmp2111 = (tmp2112 if depth2 else tmp2102)
tmp2110 = (tmp2111 if depth1 else tmp2108)
tmp2106 = (tmp2107 if s0 else tmp2110)
tmp2116 = (tmp2103 if depth3 else tmp2098)
tmp2115 = (tmp2116 if depth2 else tmp2109)
tmp2114 = (tmp2115 if depth1 else tmp2111)
tmp2118 = (tmp2103 if depth2 else tmp2112)
tmp2117 = (tmp2118 if depth1 else tmp2115)
tmp2113 = (tmp2114 if s0 else tmp2117)
tmp2105 = (tmp2106 if s1 else tmp2113)
tmp2124 = (tmp2031 if depth4 else tmp2088)
tmp2123 = (tmp2124 if depth3 else tmp2103)
tmp2122 = (tmp2123 if depth2 else tmp2116)
tmp2121 = (tmp2122 if depth1 else tmp2118)
tmp2128 = (tmp2031 if depth4 else tmp2093)
tmp2127 = (tmp2128 if depth3 else tmp2103)
tmp2126 = (tmp2127 if depth2 else tmp2103)
tmp2125 = (tmp2126 if depth1 else tmp2122)
tmp2120 = (tmp2121 if s0 else tmp2125)
tmp2133 = (tmp2031 if depth4 else tmp2099)
tmp2132 = (tmp2133 if depth3 else tmp2103)
tmp2131 = (tmp2132 if depth2 else tmp2123)
tmp2130 = (tmp2131 if depth1 else tmp2126)
tmp2136 = (tmp2031 if depth3 else tmp2103)
tmp2135 = (tmp2136 if depth2 else tmp2127)
tmp2134 = (tmp2135 if depth1 else tmp2131)
tmp2129 = (tmp2130 if s0 else tmp2134)
tmp2119 = (tmp2120 if s1 else tmp2129)
tmp2104 = (tmp2105 if s2 else tmp2119)
tmp2066 = (tmp2067 if s3 else tmp2104)
tmp2143 = (tmp2031 if depth3 else tmp2124)
tmp2142 = (tmp2143 if depth2 else tmp2132)
tmp2141 = (tmp2142 if depth1 else tmp2135)
tmp2146 = (tmp2031 if depth3 else tmp2128)
tmp2145 = (tmp2146 if depth2 else tmp2136)
tmp2144 = (tmp2145 if depth1 else tmp2142)
tmp2140 = (tmp2141 if s0 else tmp2144)
tmp2150 = (tmp2031 if depth3 else tmp2133)
tmp2149 = (tmp2150 if depth2 else tmp2143)
tmp2148 = (tmp2149 if depth1 else tmp2145)
tmp2152 = (tmp2031 if depth2 else tmp2146)
tmp2151 = (tmp2152 if depth1 else tmp2149)
tmp2147 = (tmp2148 if s0 else tmp2151)
tmp2139 = (tmp2140 if s1 else tmp2147)
tmp2160 = (tmp1815 if depth6 else tmp2010)
tmp2159 = (tmp2160 if depth5 else tmp2031)
tmp2158 = (tmp2159 if depth4 else tmp2031)
tmp2157 = (tmp2158 if depth3 else tmp2031)
tmp2156 = (tmp2157 if depth2 else tmp2150)
tmp2155 = (tmp2156 if depth1 else tmp2152)
tmp2166 = (tmp1815 if depth6 else tmp2017)
tmp2165 = (tmp2166 if depth5 else tmp2031)
tmp2164 = (tmp2165 if depth4 else tmp2031)
tmp2163 = (tmp2164 if depth3 else tmp2031)
tmp2162 = (tmp2163 if depth2 else tmp2031)
tmp2161 = (tmp2162 if depth1 else tmp2156)
tmp2154 = (tmp2155 if s0 else tmp2161)
tmp2173 = (tmp1815 if depth6 else tmp2025)
tmp2172 = (tmp2173 if depth5 else tmp2031)
tmp2171 = (tmp2172 if depth4 else tmp2031)
tmp2170 = (tmp2171 if depth3 else tmp2031)
tmp2169 = (tmp2170 if depth2 else tmp2157)
tmp2168 = (tmp2169 if depth1 else tmp2162)
tmp2178 = (tmp1815 if depth5 else tmp2031)
tmp2177 = (tmp2178 if depth4 else tmp2031)
tmp2176 = (tmp2177 if depth3 else tmp2031)
tmp2175 = (tmp2176 if depth2 else tmp2163)
tmp2174 = (tmp2175 if depth1 else tmp2169)
tmp2167 = (tmp2168 if s0 else tmp2174)
tmp2153 = (tmp2154 if s1 else tmp2167)
tmp2138 = (tmp2139 if s2 else tmp2153)
tmp2184 = (tmp2177 if depth3 else tmp2158)
tmp2183 = (tmp2184 if depth2 else tmp2170)
tmp2182 = (tmp2183 if depth1 else tmp2175)
tmp2187 = (tmp2177 if depth3 else tmp2164)
tmp2186 = (tmp2187 if depth2 else tmp2176)
tmp2185 = (tmp2186 if depth1 else tmp2183)
tmp2181 = (tmp2182 if s0 else tmp2185)
tmp2191 = (tmp2177 if depth3 else tmp2171)
tmp2190 = (tmp2191 if depth2 else tmp2184)
tmp2189 = (tmp2190 if depth1 else tmp2186)
tmp2193 = (tmp2177 if depth2 else tmp2187)
tmp2192 = (tmp2193 if depth1 else tmp2190)
tmp2188 = (tmp2189 if s0 else tmp2192)
tmp2180 = (tmp2181 if s1 else tmp2188)
tmp2199 = (tmp2178 if depth4 else tmp2159)
tmp2198 = (tmp2199 if depth3 else tmp2177)
tmp2197 = (tmp2198 if depth2 else tmp2191)
tmp2196 = (tmp2197 if depth1 else tmp2193)
tmp2203 = (tmp2178 if depth4 else tmp2165)
tmp2202 = (tmp2203 if depth3 else tmp2177)
tmp2201 = (tmp2202 if depth2 else tmp2177)
tmp2200 = (tmp2201 if depth1 else tmp2197)
tmp2195 = (tmp2196 if s0 else tmp2200)
tmp2208 = (tmp2178 if depth4 else tmp2172)
tmp2207 = (tmp2208 if depth3 else tmp2177)
tmp2206 = (tmp2207 if depth2 else tmp2198)
tmp2205 = (tmp2206 if depth1 else tmp2201)
tmp2211 = (tmp2178 if depth3 else tmp2177)
tmp2210 = (tmp2211 if depth2 else tmp2202)
tmp2209 = (tmp2210 if depth1 else tmp2206)
tmp2204 = (tmp2205 if s0 else tmp2209)
tmp2194 = (tmp2195 if s1 else tmp2204)
tmp2179 = (tmp2180 if s2 else tmp2194)
tmp2137 = (tmp2138 if s3 else tmp2179)
tmp2065 = (tmp2066 if s4 else tmp2137)
tmp1913 = (tmp1914 if s5 else tmp2065)
tmp1776 = (tmp1777 if s6 else tmp1913)
tmp2221 = (tmp2178 if depth3 else tmp2199)
tmp2220 = (tmp2221 if depth2 else tmp2207)
tmp2219 = (tmp2220 if depth1 else tmp2210)
tmp2224 = (tmp2178 if depth3 else tmp2203)
tmp2223 = (tmp2224 if depth2 else tmp2211)
tmp2222 = (tmp2223 if depth1 else tmp2220)
tmp2218 = (tmp2219 if s0 else tmp2222)
tmp2228 = (tmp2178 if depth3 else tmp2208)
tmp2227 = (tmp2228 if depth2 else tmp2221)
tmp2226 = (tmp2227 if depth1 else tmp2223)
tmp2230 = (tmp2178 if depth2 else tmp2224)
tmp2229 = (tmp2230 if depth1 else tmp2227)
tmp2225 = (tmp2226 if s0 else tmp2229)
tmp2217 = (tmp2218 if s1 else tmp2225)
tmp2237 = (tmp1815 if depth5 else tmp2160)
tmp2236 = (tmp2237 if depth4 else tmp2178)
tmp2235 = (tmp2236 if depth3 else tmp2178)
tmp2234 = (tmp2235 if depth2 else tmp2228)
tmp2233 = (tmp2234 if depth1 else tmp2230)
tmp2242 = (tmp1815 if depth5 else tmp2166)
tmp2241 = (tmp2242 if depth4 else tmp2178)
tmp2240 = (tmp2241 if depth3 else tmp2178)
tmp2239 = (tmp2240 if depth2 else tmp2178)
tmp2238 = (tmp2239 if depth1 else tmp2234)
tmp2232 = (tmp2233 if s0 else tmp2238)
tmp2248 = (tmp1815 if depth5 else tmp2173)
tmp2247 = (tmp2248 if depth4 else tmp2178)
tmp2246 = (tmp2247 if depth3 else tmp2178)
tmp2245 = (tmp2246 if depth2 else tmp2235)
tmp2244 = (tmp2245 if depth1 else tmp2239)
tmp2252 = (tmp1815 if depth4 else tmp2178)
tmp2251 = (tmp2252 if depth3 else tmp2178)
tmp2250 = (tmp2251 if depth2 else tmp2240)
tmp2249 = (tmp2250 if depth1 else tmp2245)
tmp2243 = (tmp2244 if s0 else tmp2249)
tmp2231 = (tmp2232 if s1 else tmp2243)
tmp2216 = (tmp2217 if s2 else tmp2231)
tmp2258 = (tmp2252 if depth3 else tmp2236)
tmp2257 = (tmp2258 if depth2 else tmp2246)
tmp2256 = (tmp2257 if depth1 else tmp2250)
tmp2261 = (tmp2252 if depth3 else tmp2241)
tmp2260 = (tmp2261 if depth2 else tmp2251)
tmp2259 = (tmp2260 if depth1 else tmp2257)
tmp2255 = (tmp2256 if s0 else tmp2259)
tmp2265 = (tmp2252 if depth3 else tmp2247)
tmp2264 = (tmp2265 if depth2 else tmp2258)
tmp2263 = (tmp2264 if depth1 else tmp2260)
tmp2267 = (tmp2252 if depth2 else tmp2261)
tmp2266 = (tmp2267 if depth1 else tmp2264)
tmp2262 = (tmp2263 if s0 else tmp2266)
tmp2254 = (tmp2255 if s1 else tmp2262)
tmp2273 = (tmp1815 if depth4 else tmp2237)
tmp2272 = (tmp2273 if depth3 else tmp2252)
tmp2271 = (tmp2272 if depth2 else tmp2265)
tmp2270 = (tmp2271 if depth1 else tmp2267)
tmp2277 = (tmp1815 if depth4 else tmp2242)
tmp2276 = (tmp2277 if depth3 else tmp2252)
tmp2275 = (tmp2276 if depth2 else tmp2252)
tmp2274 = (tmp2275 if depth1 else tmp2271)
tmp2269 = (tmp2270 if s0 else tmp2274)
tmp2282 = (tmp1815 if depth4 else tmp2248)
tmp2281 = (tmp2282 if depth3 else tmp2252)
tmp2280 = (tmp2281 if depth2 else tmp2272)
tmp2279 = (tmp2280 if depth1 else tmp2275)
tmp2285 = (tmp1815 if depth3 else tmp2252)
tmp2284 = (tmp2285 if depth2 else tmp2276)
tmp2283 = (tmp2284 if depth1 else tmp2280)
tmp2278 = (tmp2279 if s0 else tmp2283)
tmp2268 = (tmp2269 if s1 else tmp2278)
tmp2253 = (tmp2254 if s2 else tmp2268)
tmp2215 = (tmp2216 if s3 else tmp2253)
tmp2292 = (tmp1815 if depth3 else tmp2273)
tmp2291 = (tmp2292 if depth2 else tmp2281)
tmp2290 = (tmp2291 if depth1 else tmp2284)
tmp2295 = (tmp1815 if depth3 else tmp2277)
tmp2294 = (tmp2295 if depth2 else tmp2285)
tmp2293 = (tmp2294 if depth1 else tmp2291)
tmp2289 = (tmp2290 if s0 else tmp2293)
tmp2299 = (tmp1815 if depth3 else tmp2282)
tmp2298 = (tmp2299 if depth2 else tmp2292)
tmp2297 = (tmp2298 if depth1 else tmp2294)
tmp2301 = (tmp1815 if depth2 else tmp2295)
tmp2300 = (tmp2301 if depth1 else tmp2298)
tmp2296 = (tmp2297 if s0 else tmp2300)
tmp2288 = (tmp2289 if s1 else tmp2296)
tmp2305 = (tmp1815 if depth2 else tmp2299)
tmp2304 = (tmp2305 if depth1 else tmp2301)
tmp2306 = (tmp1815 if depth1 else tmp2305)
tmp2303 = (tmp2304 if s0 else tmp2306)
tmp2302 = (tmp2303 if s1 else tmp1779)
tmp2287 = (tmp2288 if s2 else tmp2302)
tmp2308 = (tmp1808 if s1 else tmp1841)
tmp2309 = (tmp1848 if s1 else tmp1855)
tmp2307 = (tmp2308 if s2 else tmp2309)
tmp2286 = (tmp2287 if s3 else tmp2307)
tmp2214 = (tmp2215 if s4 else tmp2286)
tmp2313 = (tmp1868 if s1 else tmp1882)
tmp2314 = (tmp1889 if s1 else tmp1896)
tmp2312 = (tmp2313 if s2 else tmp2314)
tmp2316 = (tmp1905 if s1 else tmp1918)
tmp2317 = (tmp1925 if s1 else tmp1932)
tmp2315 = (tmp2316 if s2 else tmp2317)
tmp2311 = (tmp2312 if s3 else tmp2315)
tmp2320 = (tmp1943 if s1 else tmp1955)
tmp2321 = (tmp1962 if s1 else tmp1969)
tmp2319 = (tmp2320 if s2 else tmp2321)
tmp2323 = (tmp1978 if s1 else tmp1989)
tmp2324 = (tmp1996 if s1 else tmp2003)
tmp2322 = (tmp2323 if s2 else tmp2324)
tmp2318 = (tmp2319 if s3 else tmp2322)
tmp2310 = (tmp2311 if s4 else tmp2318)
tmp2213 = (tmp2214 if s5 else tmp2310)
tmp2329 = (tmp2018 if s1 else tmp2034)
tmp2330 = (tmp2041 if s1 else tmp2048)
tmp2328 = (tmp2329 if s2 else tmp2330)
tmp2332 = (tmp2057 if s1 else tmp2069)
tmp2333 = (tmp2076 if s1 else tmp2083)
tmp2331 = (tmp2332 if s2 else tmp2333)
tmp2327 = (tmp2328 if s3 else tmp2331)
tmp2336 = (tmp2094 if s1 else tmp2106)
tmp2337 = (tmp2113 if s1 else tmp2120)
tmp2335 = (tmp2336 if s2 else tmp2337)
tmp2339 = (tmp2129 if s1 else tmp2140)
tmp2340 = (tmp2147 if s1 else tmp2154)
tmp2338 = (tmp2339 if s2 else tmp2340)
tmp2334 = (tmp2335 if s3 else tmp2338)
tmp2326 = (tmp2327 if s4 else tmp2334)
tmp2344 = (tmp2167 if s1 else tmp2181)
tmp2345 = (tmp2188 if s1 else tmp2195)
tmp2343 = (tmp2344 if s2 else tmp2345)
tmp2347 = (tmp2204 if s1 else tmp2218)
tmp2348 = (tmp2225 if s1 else tmp2232)
tmp2346 = (tmp2347 if s2 else tmp2348)
tmp2342 = (tmp2343 if s3 else tmp2346)
tmp2351 = (tmp2243 if s1 else tmp2255)
tmp2352 = (tmp2262 if s1 else tmp2269)
tmp2350 = (tmp2351 if s2 else tmp2352)
tmp2354 = (tmp2278 if s1 else tmp2289)
tmp2355 = (tmp2296 if s1 else tmp2303)
tmp2353 = (tmp2354 if s2 else tmp2355)
tmp2349 = (tmp2350 if s3 else tmp2353)
tmp2341 = (tmp2342 if s4 else tmp2349)
tmp2325 = (tmp2326 if s5 else tmp2341)
tmp2212 = (tmp2213 if s6 else tmp2325)
tmp1775 = (tmp1776 if s7 else tmp2212)
action4__s = tmp1775
recovery__s = 0
tmp2373 = (1 if action1_1 else 0)
tmp2372 = (1 if action2_1 else tmp2373)
tmp2371 = (1 if action3_1 else tmp2372)
tmp2370 = (tmp2371 if action4_1 else 0)
tmp2378 = (1 - (1 if action1_1 else 0))
tmp2377 = (tmp2373 if action2_1 else tmp2378)
tmp2379 = (1 if action2_1 else tmp2378)
tmp2376 = (tmp2377 if action3_1 else tmp2379)
tmp2375 = (1 if action4_1 else tmp2376)
tmp2374 = (tmp2375 if oxygen_low else tmp2370)
tmp2369 = (tmp2370 if oxygen_full else tmp2374)
tmp2368 = (tmp2369 if depth7 else tmp2370)
tmp2367 = (tmp2368 if depth6 else tmp2370)
tmp2383 = (tmp2369 if k2 else tmp2370)
tmp2382 = (tmp2383 if depth7 else tmp2370)
tmp2381 = (tmp2382 if depth6 else tmp2370)
tmp2380 = (tmp2367 if depth5 else tmp2381)
tmp2366 = (tmp2367 if depth4 else tmp2380)
tmp2392 = (1 - (tmp2377 if action3_1 else tmp2379))
tmp2391 = (tmp2371 if action4_1 else tmp2392)
tmp2390 = (tmp2370 if oxygen_low else tmp2391)
tmp2389 = (tmp2370 if oxygen_full else tmp2390)
tmp2388 = (tmp2370 if diver_found else tmp2389)
tmp2387 = (tmp2370 if depth7 else tmp2388)
tmp2386 = (tmp2370 if depth6 else tmp2387)
tmp2385 = (tmp2367 if depth5 else tmp2386)
tmp2384 = (tmp2367 if depth4 else tmp2385)
tmp2365 = (tmp2366 if depth3 else tmp2384)
tmp2395 = (tmp2367 if depth5 else tmp2370)
tmp2394 = (tmp2367 if depth4 else tmp2395)
tmp2393 = (tmp2394 if depth3 else tmp2384)
tmp2364 = (tmp2365 if depth2 else tmp2393)
tmp2402 = (tmp2383 if k1 else tmp2370)
tmp2401 = (tmp2402 if depth7 else tmp2370)
tmp2400 = (tmp2401 if depth6 else tmp2370)
tmp2399 = (tmp2367 if depth5 else tmp2400)
tmp2398 = (tmp2367 if depth4 else tmp2399)
tmp2397 = (tmp2398 if depth3 else tmp2384)
tmp2408 = (tmp2369 if k1 else tmp2383)
tmp2407 = (tmp2408 if depth7 else tmp2370)
tmp2406 = (tmp2407 if depth6 else tmp2370)
tmp2405 = (tmp2367 if depth5 else tmp2406)
tmp2404 = (tmp2405 if depth4 else tmp2385)
tmp2403 = (tmp2384 if depth3 else tmp2404)
tmp2396 = (tmp2397 if depth2 else tmp2403)
tmp2363 = (1 - (tmp2364 if depth1 else tmp2396))
tmp2362 = (1 if s1 else tmp2363)
tmp2361 = (1 if s2 else tmp2362)
tmp2418 = (tmp2370 if oxygen_full else tmp2375)
tmp2417 = (tmp2418 if depth7 else tmp2370)
tmp2416 = (tmp2417 if depth6 else tmp2370)
tmp2423 = (tmp2418 if k2 else tmp2370)
tmp2422 = (tmp2418 if k1 else tmp2423)
tmp2421 = (tmp2422 if depth7 else tmp2370)
tmp2420 = (tmp2421 if depth6 else tmp2370)
tmp2419 = (tmp2416 if depth5 else tmp2420)
tmp2415 = (tmp2416 if depth4 else tmp2419)
tmp2425 = (tmp2416 if depth5 else tmp2370)
tmp2424 = (tmp2416 if depth4 else tmp2425)
tmp2414 = (tmp2415 if depth3 else tmp2424)
tmp2431 = (tmp2423 if k1 else tmp2370)
tmp2430 = (tmp2431 if depth7 else tmp2370)
tmp2429 = (tmp2430 if depth6 else tmp2370)
tmp2428 = (tmp2416 if depth5 else tmp2429)
tmp2427 = (tmp2416 if depth4 else tmp2428)
tmp2426 = (tmp2427 if depth3 else tmp2424)
tmp2413 = (tmp2414 if depth2 else tmp2426)
tmp2437 = (tmp2423 if depth7 else tmp2370)
tmp2436 = (tmp2437 if depth6 else tmp2370)
tmp2435 = (tmp2416 if depth5 else tmp2436)
tmp2434 = (tmp2416 if depth4 else tmp2435)
tmp2433 = (tmp2434 if depth3 else tmp2424)
tmp2432 = (tmp2433 if depth2 else tmp2424)
tmp2412 = (tmp2413 if depth1 else tmp2432)
tmp2440 = (tmp2416 if depth3 else tmp2424)
tmp2439 = (tmp2440 if depth2 else tmp2433)
tmp2438 = (tmp2439 if depth1 else tmp2413)
tmp2411 = (tmp2412 if s0 else tmp2438)
tmp2444 = (tmp2416 if depth3 else tmp2427)
tmp2443 = (tmp2444 if depth2 else tmp2414)
tmp2442 = (tmp2443 if depth1 else tmp2439)
tmp2447 = (tmp2416 if depth3 else tmp2434)
tmp2446 = (tmp2447 if depth2 else tmp2440)
tmp2445 = (tmp2446 if depth1 else tmp2443)
tmp2441 = (tmp2442 if s0 else tmp2445)
tmp2410 = (tmp2411 if s1 else tmp2441)
tmp2452 = (tmp2416 if depth3 else tmp2415)
tmp2451 = (tmp2452 if depth2 else tmp2444)
tmp2450 = (tmp2451 if depth1 else tmp2446)
tmp2454 = (tmp2416 if depth2 else tmp2447)
tmp2453 = (tmp2454 if depth1 else tmp2451)
tmp2449 = (tmp2450 if s0 else tmp2453)
tmp2461 = (tmp2417 if depth6 else tmp2430)
tmp2460 = (tmp2461 if depth5 else tmp2416)
tmp2459 = (tmp2460 if depth4 else tmp2416)
tmp2458 = (tmp2459 if depth3 else tmp2416)
tmp2457 = (tmp2458 if depth2 else tmp2452)
tmp2456 = (tmp2457 if depth1 else tmp2454)
tmp2467 = (tmp2417 if depth6 else tmp2437)
tmp2466 = (tmp2467 if depth5 else tmp2416)
tmp2465 = (tmp2466 if depth4 else tmp2416)
tmp2464 = (tmp2465 if depth3 else tmp2416)
tmp2463 = (tmp2464 if depth2 else tmp2416)
tmp2462 = (tmp2463 if depth1 else tmp2457)
tmp2455 = (tmp2456 if s0 else tmp2462)
tmp2448 = (tmp2449 if s1 else tmp2455)
tmp2409 = (1 - (tmp2410 if s2 else tmp2448))
tmp2360 = (tmp2361 if s3 else tmp2409)
tmp2359 = (1 if s4 else tmp2360)
tmp2478 = (tmp2417 if depth6 else tmp2421)
tmp2477 = (tmp2478 if depth5 else tmp2416)
tmp2476 = (tmp2477 if depth4 else tmp2416)
tmp2475 = (tmp2476 if depth3 else tmp2416)
tmp2474 = (tmp2475 if depth2 else tmp2458)
tmp2473 = (tmp2474 if depth1 else tmp2463)
tmp2483 = (tmp2417 if depth5 else tmp2416)
tmp2482 = (tmp2483 if depth4 else tmp2416)
tmp2481 = (tmp2482 if depth3 else tmp2416)
tmp2480 = (tmp2481 if depth2 else tmp2464)
tmp2479 = (tmp2480 if depth1 else tmp2474)
tmp2472 = (tmp2473 if s0 else tmp2479)
tmp2487 = (tmp2482 if depth3 else tmp2459)
tmp2486 = (tmp2487 if depth2 else tmp2475)
tmp2485 = (tmp2486 if depth1 else tmp2480)
tmp2490 = (tmp2482 if depth3 else tmp2465)
tmp2489 = (tmp2490 if depth2 else tmp2481)
tmp2488 = (tmp2489 if depth1 else tmp2486)
tmp2484 = (tmp2485 if s0 else tmp2488)
tmp2471 = (tmp2472 if s1 else tmp2484)
tmp2495 = (tmp2482 if depth3 else tmp2476)
tmp2494 = (tmp2495 if depth2 else tmp2487)
tmp2493 = (tmp2494 if depth1 else tmp2489)
tmp2497 = (tmp2482 if depth2 else tmp2490)
tmp2496 = (tmp2497 if depth1 else tmp2494)
tmp2492 = (tmp2493 if s0 else tmp2496)
tmp2502 = (tmp2483 if depth4 else tmp2460)
tmp2501 = (tmp2502 if depth3 else tmp2482)
tmp2500 = (tmp2501 if depth2 else tmp2495)
tmp2499 = (tmp2500 if depth1 else tmp2497)
tmp2506 = (tmp2483 if depth4 else tmp2466)
tmp2505 = (tmp2506 if depth3 else tmp2482)
tmp2504 = (tmp2505 if depth2 else tmp2482)
tmp2503 = (tmp2504 if depth1 else tmp2500)
tmp2498 = (tmp2499 if s0 else tmp2503)
tmp2491 = (tmp2492 if s1 else tmp2498)
tmp2470 = (tmp2471 if s2 else tmp2491)
tmp2513 = (tmp2483 if depth4 else tmp2477)
tmp2512 = (tmp2513 if depth3 else tmp2482)
tmp2511 = (tmp2512 if depth2 else tmp2501)
tmp2510 = (tmp2511 if depth1 else tmp2504)
tmp2516 = (tmp2483 if depth3 else tmp2482)
tmp2515 = (tmp2516 if depth2 else tmp2505)
tmp2514 = (tmp2515 if depth1 else tmp2511)
tmp2509 = (tmp2510 if s0 else tmp2514)
tmp2520 = (tmp2483 if depth3 else tmp2502)
tmp2519 = (tmp2520 if depth2 else tmp2512)
tmp2518 = (tmp2519 if depth1 else tmp2515)
tmp2523 = (tmp2483 if depth3 else tmp2506)
tmp2522 = (tmp2523 if depth2 else tmp2516)
tmp2521 = (tmp2522 if depth1 else tmp2519)
tmp2517 = (tmp2518 if s0 else tmp2521)
tmp2508 = (tmp2509 if s1 else tmp2517)
tmp2528 = (tmp2483 if depth3 else tmp2513)
tmp2527 = (tmp2528 if depth2 else tmp2520)
tmp2526 = (tmp2527 if depth1 else tmp2522)
tmp2530 = (tmp2483 if depth2 else tmp2523)
tmp2529 = (tmp2530 if depth1 else tmp2527)
tmp2525 = (tmp2526 if s0 else tmp2529)
tmp2536 = (tmp2417 if depth5 else tmp2461)
tmp2535 = (tmp2536 if depth4 else tmp2483)
tmp2534 = (tmp2535 if depth3 else tmp2483)
tmp2533 = (tmp2534 if depth2 else tmp2528)
tmp2532 = (tmp2533 if depth1 else tmp2530)
tmp2541 = (tmp2417 if depth5 else tmp2467)
tmp2540 = (tmp2541 if depth4 else tmp2483)
tmp2539 = (tmp2540 if depth3 else tmp2483)
tmp2538 = (tmp2539 if depth2 else tmp2483)
tmp2537 = (tmp2538 if depth1 else tmp2533)
tmp2531 = (tmp2532 if s0 else tmp2537)
tmp2524 = (tmp2525 if s1 else tmp2531)
tmp2507 = (tmp2508 if s2 else tmp2524)
tmp2469 = (tmp2470 if s3 else tmp2507)
tmp2550 = (tmp2417 if depth5 else tmp2478)
tmp2549 = (tmp2550 if depth4 else tmp2483)
tmp2548 = (tmp2549 if depth3 else tmp2483)
tmp2547 = (tmp2548 if depth2 else tmp2534)
tmp2546 = (tmp2547 if depth1 else tmp2538)
tmp2554 = (tmp2417 if depth4 else tmp2483)
tmp2553 = (tmp2554 if depth3 else tmp2483)
tmp2552 = (tmp2553 if depth2 else tmp2539)
tmp2551 = (tmp2552 if depth1 else tmp2547)
tmp2545 = (tmp2546 if s0 else tmp2551)
tmp2558 = (tmp2554 if depth3 else tmp2535)
tmp2557 = (tmp2558 if depth2 else tmp2548)
tmp2556 = (tmp2557 if depth1 else tmp2552)
tmp2561 = (tmp2554 if depth3 else tmp2540)
tmp2560 = (tmp2561 if depth2 else tmp2553)
tmp2559 = (tmp2560 if depth1 else tmp2557)
tmp2555 = (tmp2556 if s0 else tmp2559)
tmp2544 = (tmp2545 if s1 else tmp2555)
tmp2566 = (tmp2554 if depth3 else tmp2549)
tmp2565 = (tmp2566 if depth2 else tmp2558)
tmp2564 = (tmp2565 if depth1 else tmp2560)
tmp2568 = (tmp2554 if depth2 else tmp2561)
tmp2567 = (tmp2568 if depth1 else tmp2565)
tmp2563 = (tmp2564 if s0 else tmp2567)
tmp2573 = (tmp2417 if depth4 else tmp2536)
tmp2572 = (tmp2573 if depth3 else tmp2554)
tmp2571 = (tmp2572 if depth2 else tmp2566)
tmp2570 = (tmp2571 if depth1 else tmp2568)
tmp2577 = (tmp2417 if depth4 else tmp2541)
tmp2576 = (tmp2577 if depth3 else tmp2554)
tmp2575 = (tmp2576 if depth2 else tmp2554)
tmp2574 = (tmp2575 if depth1 else tmp2571)
tmp2569 = (tmp2570 if s0 else tmp2574)
tmp2562 = (tmp2563 if s1 else tmp2569)
tmp2543 = (tmp2544 if s2 else tmp2562)
tmp2584 = (tmp2417 if depth4 else tmp2550)
tmp2583 = (tmp2584 if depth3 else tmp2554)
tmp2582 = (tmp2583 if depth2 else tmp2572)
tmp2581 = (tmp2582 if depth1 else tmp2575)
tmp2587 = (tmp2417 if depth3 else tmp2554)
tmp2586 = (tmp2587 if depth2 else tmp2576)
tmp2585 = (tmp2586 if depth1 else tmp2582)
tmp2580 = (tmp2581 if s0 else tmp2585)
tmp2591 = (tmp2417 if depth3 else tmp2573)
tmp2590 = (tmp2591 if depth2 else tmp2583)
tmp2589 = (tmp2590 if depth1 else tmp2586)
tmp2594 = (tmp2417 if depth3 else tmp2577)
tmp2593 = (tmp2594 if depth2 else tmp2587)
tmp2592 = (tmp2593 if depth1 else tmp2590)
tmp2588 = (tmp2589 if s0 else tmp2592)
tmp2579 = (tmp2580 if s1 else tmp2588)
tmp2599 = (tmp2417 if depth3 else tmp2584)
tmp2598 = (tmp2599 if depth2 else tmp2591)
tmp2597 = (tmp2598 if depth1 else tmp2593)
tmp2601 = (tmp2417 if depth2 else tmp2594)
tmp2600 = (tmp2601 if depth1 else tmp2598)
tmp2596 = (tmp2597 if s0 else tmp2600)
tmp2609 = (tmp2418 if depth7 else tmp2431)
tmp2608 = (tmp2609 if depth6 else tmp2417)
tmp2607 = (tmp2608 if depth5 else tmp2417)
tmp2606 = (tmp2607 if depth4 else tmp2417)
tmp2605 = (tmp2606 if depth3 else tmp2417)
tmp2604 = (tmp2605 if depth2 else tmp2599)
tmp2603 = (tmp2604 if depth1 else tmp2601)
tmp2616 = (tmp2418 if depth7 else tmp2423)
tmp2615 = (tmp2616 if depth6 else tmp2417)
tmp2614 = (tmp2615 if depth5 else tmp2417)
tmp2613 = (tmp2614 if depth4 else tmp2417)
tmp2612 = (tmp2613 if depth3 else tmp2417)
tmp2611 = (tmp2612 if depth2 else tmp2417)
tmp2610 = (tmp2611 if depth1 else tmp2604)
tmp2602 = (tmp2603 if s0 else tmp2610)
tmp2595 = (tmp2596 if s1 else tmp2602)
tmp2578 = (tmp2579 if s2 else tmp2595)
tmp2542 = (tmp2543 if s3 else tmp2578)
tmp2468 = (1 - (tmp2469 if s4 else tmp2542))
tmp2358 = (tmp2359 if s5 else tmp2468)
tmp2629 = (tmp2418 if depth7 else tmp2422)
tmp2628 = (tmp2629 if depth6 else tmp2417)
tmp2627 = (tmp2628 if depth5 else tmp2417)
tmp2626 = (tmp2627 if depth4 else tmp2417)
tmp2625 = (tmp2626 if depth3 else tmp2417)
tmp2624 = (tmp2625 if depth2 else tmp2605)
tmp2623 = (tmp2624 if depth1 else tmp2611)
tmp2635 = (tmp2418 if depth6 else tmp2417)
tmp2634 = (tmp2635 if depth5 else tmp2417)
tmp2633 = (tmp2634 if depth4 else tmp2417)
tmp2632 = (tmp2633 if depth3 else tmp2417)
tmp2631 = (tmp2632 if depth2 else tmp2612)
tmp2630 = (tmp2631 if depth1 else tmp2624)
tmp2622 = (tmp2623 if s0 else tmp2630)
tmp2639 = (tmp2633 if depth3 else tmp2606)
tmp2638 = (tmp2639 if depth2 else tmp2625)
tmp2637 = (tmp2638 if depth1 else tmp2631)
tmp2642 = (tmp2633 if depth3 else tmp2613)
tmp2641 = (tmp2642 if depth2 else tmp2632)
tmp2640 = (tmp2641 if depth1 else tmp2638)
tmp2636 = (tmp2637 if s0 else tmp2640)
tmp2621 = (tmp2622 if s1 else tmp2636)
tmp2647 = (tmp2633 if depth3 else tmp2626)
tmp2646 = (tmp2647 if depth2 else tmp2639)
tmp2645 = (tmp2646 if depth1 else tmp2641)
tmp2649 = (tmp2633 if depth2 else tmp2642)
tmp2648 = (tmp2649 if depth1 else tmp2646)
tmp2644 = (tmp2645 if s0 else tmp2648)
tmp2654 = (tmp2634 if depth4 else tmp2607)
tmp2653 = (tmp2654 if depth3 else tmp2633)
tmp2652 = (tmp2653 if depth2 else tmp2647)
tmp2651 = (tmp2652 if depth1 else tmp2649)
tmp2658 = (tmp2634 if depth4 else tmp2614)
tmp2657 = (tmp2658 if depth3 else tmp2633)
tmp2656 = (tmp2657 if depth2 else tmp2633)
tmp2655 = (tmp2656 if depth1 else tmp2652)
tmp2650 = (tmp2651 if s0 else tmp2655)
tmp2643 = (tmp2644 if s1 else tmp2650)
tmp2620 = (tmp2621 if s2 else tmp2643)
tmp2665 = (tmp2634 if depth4 else tmp2627)
tmp2664 = (tmp2665 if depth3 else tmp2633)
tmp2663 = (tmp2664 if depth2 else tmp2653)
tmp2662 = (tmp2663 if depth1 else tmp2656)
tmp2668 = (tmp2634 if depth3 else tmp2633)
tmp2667 = (tmp2668 if depth2 else tmp2657)
tmp2666 = (tmp2667 if depth1 else tmp2663)
tmp2661 = (tmp2662 if s0 else tmp2666)
tmp2672 = (tmp2634 if depth3 else tmp2654)
tmp2671 = (tmp2672 if depth2 else tmp2664)
tmp2670 = (tmp2671 if depth1 else tmp2667)
tmp2675 = (tmp2634 if depth3 else tmp2658)
tmp2674 = (tmp2675 if depth2 else tmp2668)
tmp2673 = (tmp2674 if depth1 else tmp2671)
tmp2669 = (tmp2670 if s0 else tmp2673)
tmp2660 = (tmp2661 if s1 else tmp2669)
tmp2680 = (tmp2634 if depth3 else tmp2665)
tmp2679 = (tmp2680 if depth2 else tmp2672)
tmp2678 = (tmp2679 if depth1 else tmp2674)
tmp2682 = (tmp2634 if depth2 else tmp2675)
tmp2681 = (tmp2682 if depth1 else tmp2679)
tmp2677 = (tmp2678 if s0 else tmp2681)
tmp2688 = (tmp2635 if depth5 else tmp2608)
tmp2687 = (tmp2688 if depth4 else tmp2634)
tmp2686 = (tmp2687 if depth3 else tmp2634)
tmp2685 = (tmp2686 if depth2 else tmp2680)
tmp2684 = (tmp2685 if depth1 else tmp2682)
tmp2693 = (tmp2635 if depth5 else tmp2615)
tmp2692 = (tmp2693 if depth4 else tmp2634)
tmp2691 = (tmp2692 if depth3 else tmp2634)
tmp2690 = (tmp2691 if depth2 else tmp2634)
tmp2689 = (tmp2690 if depth1 else tmp2685)
tmp2683 = (tmp2684 if s0 else tmp2689)
tmp2676 = (tmp2677 if s1 else tmp2683)
tmp2659 = (tmp2660 if s2 else tmp2676)
tmp2619 = (tmp2620 if s3 else tmp2659)
tmp2702 = (tmp2635 if depth5 else tmp2628)
tmp2701 = (tmp2702 if depth4 else tmp2634)
tmp2700 = (tmp2701 if depth3 else tmp2634)
tmp2699 = (tmp2700 if depth2 else tmp2686)
tmp2698 = (tmp2699 if depth1 else tmp2690)
tmp2706 = (tmp2635 if depth4 else tmp2634)
tmp2705 = (tmp2706 if depth3 else tmp2634)
tmp2704 = (tmp2705 if depth2 else tmp2691)
tmp2703 = (tmp2704 if depth1 else tmp2699)
tmp2697 = (tmp2698 if s0 else tmp2703)
tmp2710 = (tmp2706 if depth3 else tmp2687)
tmp2709 = (tmp2710 if depth2 else tmp2700)
tmp2708 = (tmp2709 if depth1 else tmp2704)
tmp2713 = (tmp2706 if depth3 else tmp2692)
tmp2712 = (tmp2713 if depth2 else tmp2705)
tmp2711 = (tmp2712 if depth1 else tmp2709)
tmp2707 = (tmp2708 if s0 else tmp2711)
tmp2696 = (tmp2697 if s1 else tmp2707)
tmp2718 = (tmp2706 if depth3 else tmp2701)
tmp2717 = (tmp2718 if depth2 else tmp2710)
tmp2716 = (tmp2717 if depth1 else tmp2712)
tmp2720 = (tmp2706 if depth2 else tmp2713)
tmp2719 = (tmp2720 if depth1 else tmp2717)
tmp2715 = (tmp2716 if s0 else tmp2719)
tmp2725 = (tmp2635 if depth4 else tmp2688)
tmp2724 = (tmp2725 if depth3 else tmp2706)
tmp2723 = (tmp2724 if depth2 else tmp2718)
tmp2722 = (tmp2723 if depth1 else tmp2720)
tmp2729 = (tmp2635 if depth4 else tmp2693)
tmp2728 = (tmp2729 if depth3 else tmp2706)
tmp2727 = (tmp2728 if depth2 else tmp2706)
tmp2726 = (tmp2727 if depth1 else tmp2723)
tmp2721 = (tmp2722 if s0 else tmp2726)
tmp2714 = (tmp2715 if s1 else tmp2721)
tmp2695 = (tmp2696 if s2 else tmp2714)
tmp2736 = (tmp2635 if depth4 else tmp2702)
tmp2735 = (tmp2736 if depth3 else tmp2706)
tmp2734 = (tmp2735 if depth2 else tmp2724)
tmp2733 = (tmp2734 if depth1 else tmp2727)
tmp2739 = (tmp2635 if depth3 else tmp2706)
tmp2738 = (tmp2739 if depth2 else tmp2728)
tmp2737 = (tmp2738 if depth1 else tmp2734)
tmp2732 = (tmp2733 if s0 else tmp2737)
tmp2743 = (tmp2635 if depth3 else tmp2725)
tmp2742 = (tmp2743 if depth2 else tmp2735)
tmp2741 = (tmp2742 if depth1 else tmp2738)
tmp2746 = (tmp2635 if depth3 else tmp2729)
tmp2745 = (tmp2746 if depth2 else tmp2739)
tmp2744 = (tmp2745 if depth1 else tmp2742)
tmp2740 = (tmp2741 if s0 else tmp2744)
tmp2731 = (tmp2732 if s1 else tmp2740)
tmp2751 = (tmp2635 if depth3 else tmp2736)
tmp2750 = (tmp2751 if depth2 else tmp2743)
tmp2749 = (tmp2750 if depth1 else tmp2745)
tmp2753 = (tmp2635 if depth2 else tmp2746)
tmp2752 = (tmp2753 if depth1 else tmp2750)
tmp2748 = (tmp2749 if s0 else tmp2752)
tmp2760 = (tmp2418 if depth6 else tmp2609)
tmp2759 = (tmp2760 if depth5 else tmp2635)
tmp2758 = (tmp2759 if depth4 else tmp2635)
tmp2757 = (tmp2758 if depth3 else tmp2635)
tmp2756 = (tmp2757 if depth2 else tmp2751)
tmp2755 = (tmp2756 if depth1 else tmp2753)
tmp2766 = (tmp2418 if depth6 else tmp2616)
tmp2765 = (tmp2766 if depth5 else tmp2635)
tmp2764 = (tmp2765 if depth4 else tmp2635)
tmp2763 = (tmp2764 if depth3 else tmp2635)
tmp2762 = (tmp2763 if depth2 else tmp2635)
tmp2761 = (tmp2762 if depth1 else tmp2756)
tmp2754 = (tmp2755 if s0 else tmp2761)
tmp2747 = (tmp2748 if s1 else tmp2754)
tmp2730 = (tmp2731 if s2 else tmp2747)
tmp2694 = (tmp2695 if s3 else tmp2730)
tmp2618 = (tmp2619 if s4 else tmp2694)
tmp2777 = (tmp2418 if depth6 else tmp2629)
tmp2776 = (tmp2777 if depth5 else tmp2635)
tmp2775 = (tmp2776 if depth4 else tmp2635)
tmp2774 = (tmp2775 if depth3 else tmp2635)
tmp2773 = (tmp2774 if depth2 else tmp2757)
tmp2772 = (tmp2773 if depth1 else tmp2762)
tmp2782 = (tmp2418 if depth5 else tmp2635)
tmp2781 = (tmp2782 if depth4 else tmp2635)
tmp2780 = (tmp2781 if depth3 else tmp2635)
tmp2779 = (tmp2780 if depth2 else tmp2763)
tmp2778 = (tmp2779 if depth1 else tmp2773)
tmp2771 = (tmp2772 if s0 else tmp2778)
tmp2786 = (tmp2781 if depth3 else tmp2758)
tmp2785 = (tmp2786 if depth2 else tmp2774)
tmp2784 = (tmp2785 if depth1 else tmp2779)
tmp2789 = (tmp2781 if depth3 else tmp2764)
tmp2788 = (tmp2789 if depth2 else tmp2780)
tmp2787 = (tmp2788 if depth1 else tmp2785)
tmp2783 = (tmp2784 if s0 else tmp2787)
tmp2770 = (tmp2771 if s1 else tmp2783)
tmp2794 = (tmp2781 if depth3 else tmp2775)
tmp2793 = (tmp2794 if depth2 else tmp2786)
tmp2792 = (tmp2793 if depth1 else tmp2788)
tmp2796 = (tmp2781 if depth2 else tmp2789)
tmp2795 = (tmp2796 if depth1 else tmp2793)
tmp2791 = (tmp2792 if s0 else tmp2795)
tmp2804 = (tmp2370 if oxygen_full else 0)
tmp2803 = (tmp2804 if k2 else tmp2418)
tmp2802 = (tmp2803 if k1 else tmp2418)
tmp2808 = (tmp2804 if k2 else tmp2370)
tmp2807 = (tmp2808 if k1 else tmp2370)
tmp2806 = (tmp2802 if depth7 else tmp2807)
tmp2805 = (tmp2802 if depth6 else tmp2806)
tmp2801 = (tmp2802 if depth5 else tmp2805)
tmp2800 = (tmp2801 if depth4 else tmp2805)
tmp2814 = (tmp2803 if k1 else tmp2423)
tmp2813 = (tmp2802 if depth7 else tmp2814)
tmp2812 = (tmp2802 if depth6 else tmp2813)
tmp2811 = (tmp2812 if depth5 else tmp2805)
tmp2810 = (tmp2811 if depth4 else tmp2805)
tmp2809 = (tmp2800 if depth3 else tmp2810)
tmp2799 = (tmp2800 if depth2 else tmp2809)
tmp2821 = (tmp2808 if k1 else tmp2423)
tmp2820 = (tmp2802 if depth7 else tmp2821)
tmp2819 = (tmp2802 if depth6 else tmp2820)
tmp2818 = (tmp2819 if depth5 else tmp2805)
tmp2817 = (tmp2818 if depth4 else tmp2805)
tmp2816 = (tmp2800 if depth3 else tmp2817)
tmp2815 = (tmp2800 if depth2 else tmp2816)
tmp2798 = (tmp2799 if depth1 else tmp2815)
tmp2826 = (tmp2803 if depth7 else tmp2808)
tmp2825 = (tmp2803 if depth6 else tmp2826)
tmp2824 = (tmp2803 if depth5 else tmp2825)
tmp2823 = (tmp2824 if depth4 else tmp2825)
tmp2833 = (tmp2803 if k1 else tmp2808)
tmp2832 = (tmp2803 if depth7 else tmp2833)
tmp2831 = (tmp2803 if depth6 else tmp2832)
tmp2830 = (tmp2831 if depth5 else tmp2825)
tmp2829 = (tmp2830 if depth4 else tmp2825)
tmp2828 = (tmp2823 if depth3 else tmp2829)
tmp2827 = (tmp2823 if depth2 else tmp2828)
tmp2822 = (tmp2823 if depth1 else tmp2827)
tmp2797 = (tmp2798 if s0 else tmp2822)
tmp2790 = (tmp2791 if s1 else tmp2797)
tmp2769 = (tmp2770 if s2 else tmp2790)
tmp2839 = (tmp2804 if k1 else tmp2803)
tmp2842 = (tmp2804 if k1 else tmp2808)
tmp2841 = (tmp2839 if depth7 else tmp2842)
tmp2840 = (tmp2839 if depth6 else tmp2841)
tmp2838 = (tmp2839 if depth5 else tmp2840)
tmp2837 = (tmp2838 if depth4 else tmp2840)
tmp2836 = (tmp2837 if s0 else tmp2804)
tmp2835 = (tmp2836 if s1 else tmp2804)
tmp2834 = (tmp2835 if s2 else tmp2804)
tmp2768 = (tmp2769 if s3 else tmp2834)
tmp2767 = (tmp2768 if s4 else tmp2804)
tmp2617 = (1 - (tmp2618 if s5 else tmp2767))
tmp2357 = (tmp2358 if s6 else tmp2617)
tmp2356 = (1 - (1 if s7 else tmp2357))
s7n = tmp2356
tmp2853 = (1 if oxygen_full else 0)
tmp2852 = (tmp2853 if k2 else 1)
tmp2851 = (tmp2852 if k1 else 1)
tmp2850 = (tmp2851 if s0 else tmp2852)
tmp2849 = (1 if s1 else tmp2850)
tmp2856 = (tmp2853 if k1 else tmp2852)
tmp2855 = (tmp2856 if s0 else tmp2853)
tmp2854 = (tmp2855 if s1 else tmp2853)
tmp2848 = (tmp2849 if s2 else tmp2854)
tmp2847 = (tmp2848 if s3 else tmp2853)
tmp2846 = (1 if s4 else tmp2847)
tmp2845 = (tmp2846 if s5 else tmp2853)
tmp2844 = (1 if s6 else tmp2845)
tmp2862 = (tmp2853 if s1 else 1)
tmp2861 = (tmp2853 if s2 else tmp2862)
tmp2860 = (tmp2861 if s3 else 1)
tmp2859 = (tmp2853 if s4 else tmp2860)
tmp2879 = (1 if action1_1 else 0)
tmp2880 = (1 - (1 if action1_1 else 0))
tmp2878 = (tmp2879 if action2_1 else tmp2880)
tmp2881 = (1 if action2_1 else tmp2880)
tmp2877 = (tmp2878 if action3_1 else tmp2881)
tmp2876 = (1 - (1 if action4_1 else tmp2877))
tmp2875 = (1 if oxygen_full else tmp2876)
tmp2874 = (tmp2875 if k2 else 1)
tmp2873 = (tmp2874 if k1 else 1)
tmp2887 = (1 if action2_1 else tmp2879)
tmp2886 = (1 if action3_1 else tmp2887)
tmp2885 = (1 - (tmp2886 if action4_1 else 0))
tmp2884 = (1 if oxygen_full else tmp2885)
tmp2883 = (tmp2884 if k2 else 1)
tmp2882 = (tmp2883 if k1 else 1)
tmp2872 = (tmp2873 if depth7 else tmp2882)
tmp2888 = (tmp2872 if depth6 else tmp2882)
tmp2871 = (tmp2872 if depth5 else tmp2888)
tmp2889 = (tmp2871 if depth4 else tmp2888)
tmp2870 = (tmp2871 if depth3 else tmp2889)
tmp2869 = (tmp2870 if depth2 else tmp2889)
tmp2868 = (tmp2869 if depth1 else tmp2889)
tmp2894 = (tmp2874 if depth7 else tmp2883)
tmp2895 = (tmp2894 if depth6 else tmp2883)
tmp2893 = (tmp2894 if depth5 else tmp2895)
tmp2896 = (tmp2893 if depth4 else tmp2895)
tmp2892 = (tmp2893 if depth3 else tmp2896)
tmp2891 = (tmp2892 if depth2 else tmp2896)
tmp2903 = (tmp2874 if k1 else tmp2883)
tmp2902 = (tmp2903 if depth7 else tmp2883)
tmp2901 = (tmp2894 if depth6 else tmp2902)
tmp2900 = (tmp2901 if depth5 else tmp2895)
tmp2899 = (tmp2893 if depth4 else tmp2900)
tmp2898 = (tmp2899 if depth3 else tmp2896)
tmp2897 = (tmp2898 if depth2 else tmp2896)
tmp2890 = (tmp2891 if depth1 else tmp2897)
tmp2867 = (tmp2868 if s0 else tmp2890)
tmp2866 = (1 if s1 else tmp2867)
tmp2865 = (1 if s2 else tmp2866)
tmp2912 = (tmp2875 if k1 else tmp2874)
tmp2913 = (tmp2884 if k1 else tmp2883)
tmp2911 = (tmp2912 if depth7 else tmp2913)
tmp2914 = (tmp2911 if depth6 else tmp2913)
tmp2910 = (tmp2911 if depth5 else tmp2914)
tmp2915 = (tmp2910 if depth4 else tmp2914)
tmp2909 = (tmp2910 if depth3 else tmp2915)
tmp2922 = (tmp2875 if k2 else tmp2884)
tmp2921 = (tmp2922 if k1 else tmp2883)
tmp2920 = (tmp2921 if depth7 else tmp2913)
tmp2919 = (tmp2911 if depth6 else tmp2920)
tmp2918 = (tmp2919 if depth5 else tmp2914)
tmp2917 = (tmp2910 if depth4 else tmp2918)
tmp2916 = (tmp2917 if depth3 else tmp2915)
tmp2908 = (tmp2909 if depth2 else tmp2916)
tmp2929 = (tmp2922 if k1 else tmp2874)
tmp2928 = (tmp2929 if depth7 else tmp2913)
tmp2927 = (tmp2911 if depth6 else tmp2928)
tmp2926 = (tmp2927 if depth5 else tmp2914)
tmp2925 = (tmp2910 if depth4 else tmp2926)
tmp2924 = (tmp2925 if depth3 else tmp2915)
tmp2923 = (tmp2924 if depth2 else tmp2915)
tmp2907 = (tmp2908 if depth1 else tmp2923)
tmp2934 = (tmp2875 if depth7 else tmp2884)
tmp2935 = (tmp2934 if depth6 else tmp2884)
tmp2933 = (tmp2934 if depth5 else tmp2935)
tmp2936 = (tmp2933 if depth4 else tmp2935)
tmp2932 = (tmp2933 if depth3 else tmp2936)
tmp2941 = (tmp2922 if depth7 else tmp2884)
tmp2940 = (tmp2934 if depth6 else tmp2941)
tmp2939 = (tmp2940 if depth5 else tmp2935)
tmp2938 = (tmp2933 if depth4 else tmp2939)
tmp2937 = (tmp2938 if depth3 else tmp2936)
tmp2931 = (tmp2932 if depth2 else tmp2937)
tmp2948 = (tmp2875 if k1 else tmp2922)
tmp2947 = (tmp2948 if depth7 else tmp2884)
tmp2946 = (tmp2934 if depth6 else tmp2947)
tmp2945 = (tmp2946 if depth5 else tmp2935)
tmp2944 = (tmp2933 if depth4 else tmp2945)
tmp2943 = (tmp2944 if depth3 else tmp2936)
tmp2954 = (tmp2922 if k1 else tmp2884)
tmp2953 = (tmp2954 if depth7 else tmp2884)
tmp2952 = (tmp2934 if depth6 else tmp2953)
tmp2951 = (tmp2952 if depth5 else tmp2935)
tmp2950 = (tmp2933 if depth4 else tmp2951)
tmp2949 = (tmp2950 if depth3 else tmp2936)
tmp2942 = (tmp2943 if depth2 else tmp2949)
tmp2930 = (tmp2931 if depth1 else tmp2942)
tmp2906 = (tmp2907 if s0 else tmp2930)
tmp2958 = (tmp2933 if depth3 else tmp2950)
tmp2957 = (tmp2958 if depth2 else tmp2943)
tmp2956 = (tmp2957 if depth1 else tmp2931)
tmp2961 = (tmp2933 if depth3 else tmp2938)
tmp2960 = (tmp2961 if depth2 else tmp2932)
tmp2959 = (tmp2960 if depth1 else tmp2957)
tmp2955 = (tmp2956 if s0 else tmp2959)
tmp2905 = (tmp2906 if s1 else tmp2955)
tmp2966 = (tmp2933 if depth3 else tmp2944)
tmp2965 = (tmp2966 if depth2 else tmp2958)
tmp2964 = (tmp2965 if depth1 else tmp2960)
tmp2968 = (tmp2933 if depth2 else tmp2961)
tmp2967 = (tmp2968 if depth1 else tmp2965)
tmp2963 = (tmp2964 if s0 else tmp2967)
tmp2974 = (tmp2934 if depth5 else tmp2952)
tmp2973 = (tmp2974 if depth4 else tmp2933)
tmp2972 = (tmp2973 if depth3 else tmp2933)
tmp2971 = (tmp2972 if depth2 else tmp2966)
tmp2970 = (tmp2971 if depth1 else tmp2968)
tmp2979 = (tmp2934 if depth5 else tmp2940)
tmp2978 = (tmp2979 if depth4 else tmp2933)
tmp2977 = (tmp2978 if depth3 else tmp2933)
tmp2976 = (tmp2977 if depth2 else tmp2933)
tmp2975 = (tmp2976 if depth1 else tmp2971)
tmp2969 = (tmp2970 if s0 else tmp2975)
tmp2962 = (tmp2963 if s1 else tmp2969)
tmp2904 = (tmp2905 if s2 else tmp2962)
tmp2864 = (tmp2865 if s3 else tmp2904)
tmp2988 = (tmp2934 if depth5 else tmp2946)
tmp2987 = (tmp2988 if depth4 else tmp2933)
tmp2986 = (tmp2987 if depth3 else tmp2933)
tmp2985 = (tmp2986 if depth2 else tmp2972)
tmp2984 = (tmp2985 if depth1 else tmp2976)
tmp2992 = (tmp2934 if depth4 else tmp2933)
tmp2991 = (tmp2992 if depth3 else tmp2933)
tmp2990 = (tmp2991 if depth2 else tmp2977)
tmp2989 = (tmp2990 if depth1 else tmp2985)
tmp2983 = (tmp2984 if s0 else tmp2989)
tmp2996 = (tmp2992 if depth3 else tmp2973)
tmp2995 = (tmp2996 if depth2 else tmp2986)
tmp2994 = (tmp2995 if depth1 else tmp2990)
tmp2999 = (tmp2992 if depth3 else tmp2978)
tmp2998 = (tmp2999 if depth2 else tmp2991)
tmp2997 = (tmp2998 if depth1 else tmp2995)
tmp2993 = (tmp2994 if s0 else tmp2997)
tmp2982 = (tmp2983 if s1 else tmp2993)
tmp3004 = (tmp2992 if depth3 else tmp2987)
tmp3003 = (tmp3004 if depth2 else tmp2996)
tmp3002 = (tmp3003 if depth1 else tmp2998)
tmp3006 = (tmp2992 if depth2 else tmp2999)
tmp3005 = (tmp3006 if depth1 else tmp3003)
tmp3001 = (tmp3002 if s0 else tmp3005)
tmp3011 = (tmp2934 if depth4 else tmp2974)
tmp3010 = (tmp3011 if depth3 else tmp2992)
tmp3009 = (tmp3010 if depth2 else tmp3004)
tmp3008 = (tmp3009 if depth1 else tmp3006)
tmp3015 = (tmp2934 if depth4 else tmp2979)
tmp3014 = (tmp3015 if depth3 else tmp2992)
tmp3013 = (tmp3014 if depth2 else tmp2992)
tmp3012 = (tmp3013 if depth1 else tmp3009)
tmp3007 = (tmp3008 if s0 else tmp3012)
tmp3000 = (tmp3001 if s1 else tmp3007)
tmp2981 = (tmp2982 if s2 else tmp3000)
tmp3022 = (tmp2934 if depth4 else tmp2988)
tmp3021 = (tmp3022 if depth3 else tmp2992)
tmp3020 = (tmp3021 if depth2 else tmp3010)
tmp3019 = (tmp3020 if depth1 else tmp3013)
tmp3025 = (tmp2934 if depth3 else tmp2992)
tmp3024 = (tmp3025 if depth2 else tmp3014)
tmp3023 = (tmp3024 if depth1 else tmp3020)
tmp3018 = (tmp3019 if s0 else tmp3023)
tmp3029 = (tmp2934 if depth3 else tmp3011)
tmp3028 = (tmp3029 if depth2 else tmp3021)
tmp3027 = (tmp3028 if depth1 else tmp3024)
tmp3032 = (tmp2934 if depth3 else tmp3015)
tmp3031 = (tmp3032 if depth2 else tmp3025)
tmp3030 = (tmp3031 if depth1 else tmp3028)
tmp3026 = (tmp3027 if s0 else tmp3030)
tmp3017 = (tmp3018 if s1 else tmp3026)
tmp3040 = (tmp2853 if k2 else tmp2875)
tmp3039 = (tmp3040 if k1 else tmp2875)
tmp3042 = (tmp2853 if k2 else tmp2884)
tmp3041 = (tmp3042 if k1 else tmp2884)
tmp3038 = (tmp3039 if depth7 else tmp3041)
tmp3047 = (tmp3040 if k1 else tmp2922)
tmp3046 = (tmp3047 if depth7 else tmp3041)
tmp3045 = (tmp3038 if depth6 else tmp3046)
tmp3044 = (tmp3038 if depth5 else tmp3045)
tmp3043 = (tmp3038 if depth4 else tmp3044)
tmp3037 = (tmp3038 if depth3 else tmp3043)
tmp3051 = (tmp3038 if depth6 else tmp3041)
tmp3050 = (tmp3038 if depth5 else tmp3051)
tmp3049 = (tmp3038 if depth4 else tmp3050)
tmp3048 = (tmp3038 if depth3 else tmp3049)
tmp3036 = (tmp3037 if depth2 else tmp3048)
tmp3058 = (tmp3042 if k1 else tmp2922)
tmp3057 = (tmp3058 if depth7 else tmp3041)
tmp3056 = (tmp3038 if depth6 else tmp3057)
tmp3055 = (tmp3038 if depth5 else tmp3056)
tmp3054 = (tmp3038 if depth4 else tmp3055)
tmp3053 = (tmp3038 if depth3 else tmp3054)
tmp3052 = (tmp3053 if depth2 else tmp3048)
tmp3035 = (tmp3036 if depth1 else tmp3052)
tmp3061 = (tmp3040 if depth7 else tmp3042)
tmp3065 = (tmp3061 if depth6 else tmp3042)
tmp3064 = (tmp3061 if depth5 else tmp3065)
tmp3063 = (tmp3061 if depth4 else tmp3064)
tmp3062 = (tmp3061 if depth3 else tmp3063)
tmp3060 = (tmp3061 if depth2 else tmp3062)
tmp3072 = (tmp3040 if k1 else tmp3042)
tmp3071 = (tmp3072 if depth7 else tmp3042)
tmp3070 = (tmp3061 if depth6 else tmp3071)
tmp3069 = (tmp3061 if depth5 else tmp3070)
tmp3068 = (tmp3061 if depth4 else tmp3069)
tmp3067 = (tmp3061 if depth3 else tmp3068)
tmp3066 = (tmp3067 if depth2 else tmp3062)
tmp3059 = (tmp3060 if depth1 else tmp3066)
tmp3034 = (tmp3035 if s0 else tmp3059)
tmp3076 = (tmp2853 if k1 else tmp3040)
tmp3077 = (tmp2853 if k1 else tmp3042)
tmp3075 = (tmp3076 if depth7 else tmp3077)
tmp3081 = (tmp3075 if depth6 else tmp3077)
tmp3080 = (tmp3075 if depth5 else tmp3081)
tmp3079 = (tmp3075 if depth4 else tmp3080)
tmp3078 = (tmp3075 if depth3 else tmp3079)
tmp3074 = (tmp3075 if depth2 else tmp3078)
tmp3073 = (tmp3074 if s0 else tmp2853)
tmp3033 = (tmp3034 if s1 else tmp3073)
tmp3016 = (tmp3017 if s2 else tmp3033)
tmp2980 = (tmp2981 if s3 else tmp3016)
tmp2863 = (tmp2864 if s4 else tmp2980)
tmp2858 = (tmp2859 if s5 else tmp2863)
tmp3095 = (1 if action4_1 else tmp2877)
tmp3094 = (1 if oxygen_full else tmp3095)
tmp3093 = (tmp3094 if k2 else tmp2853)
tmp3092 = (tmp3093 if k1 else tmp2853)
tmp3101 = (tmp2886 if action4_1 else 0)
tmp3100 = (1 if oxygen_full else tmp3101)
tmp3099 = (tmp3100 if k2 else tmp2853)
tmp3098 = (tmp3099 if k1 else tmp2853)
tmp3097 = (tmp3092 if depth7 else tmp3098)
tmp3096 = (tmp3092 if depth6 else tmp3097)
tmp3091 = (tmp3092 if depth5 else tmp3096)
tmp3102 = (tmp3091 if depth4 else tmp3096)
tmp3090 = (tmp3091 if depth3 else tmp3102)
tmp3089 = (tmp3090 if depth2 else tmp3102)
tmp3088 = (tmp3089 if depth1 else tmp3102)
tmp3108 = (tmp3093 if depth7 else tmp3099)
tmp3107 = (tmp3093 if depth6 else tmp3108)
tmp3106 = (tmp3093 if depth5 else tmp3107)
tmp3109 = (tmp3106 if depth4 else tmp3107)
tmp3105 = (tmp3106 if depth3 else tmp3109)
tmp3104 = (tmp3105 if depth2 else tmp3109)
tmp3116 = (tmp3093 if k1 else tmp3099)
tmp3115 = (tmp3093 if depth7 else tmp3116)
tmp3114 = (tmp3093 if depth6 else tmp3115)
tmp3113 = (tmp3114 if depth5 else tmp3107)
tmp3112 = (tmp3106 if depth4 else tmp3113)
tmp3111 = (tmp3112 if depth3 else tmp3109)
tmp3110 = (tmp3111 if depth2 else tmp3109)
tmp3103 = (tmp3104 if depth1 else tmp3110)
tmp3087 = (tmp3088 if s0 else tmp3103)
tmp3086 = (tmp2853 if s1 else tmp3087)
tmp3085 = (tmp2853 if s2 else tmp3086)
tmp3124 = (tmp3094 if k1 else tmp3093)
tmp3127 = (tmp3100 if k1 else tmp3099)
tmp3126 = (tmp3124 if depth7 else tmp3127)
tmp3125 = (tmp3124 if depth6 else tmp3126)
tmp3123 = (tmp3124 if depth5 else tmp3125)
tmp3128 = (tmp3123 if depth4 else tmp3125)
tmp3122 = (tmp3123 if depth3 else tmp3128)
tmp3135 = (tmp3094 if k2 else tmp3100)
tmp3134 = (tmp3135 if k1 else tmp3099)
tmp3133 = (tmp3124 if depth7 else tmp3134)
tmp3132 = (tmp3124 if depth6 else tmp3133)
tmp3131 = (tmp3132 if depth5 else tmp3125)
tmp3130 = (tmp3123 if depth4 else tmp3131)
tmp3129 = (tmp3130 if depth3 else tmp3128)
tmp3121 = (tmp3122 if depth2 else tmp3129)
tmp3142 = (tmp3135 if k1 else tmp3093)
tmp3141 = (tmp3124 if depth7 else tmp3142)
tmp3140 = (tmp3124 if depth6 else tmp3141)
tmp3139 = (tmp3140 if depth5 else tmp3125)
tmp3138 = (tmp3123 if depth4 else tmp3139)
tmp3137 = (tmp3138 if depth3 else tmp3128)
tmp3136 = (tmp3137 if depth2 else tmp3128)
tmp3120 = (tmp3121 if depth1 else tmp3136)
tmp3148 = (tmp3094 if depth7 else tmp3100)
tmp3147 = (tmp3094 if depth6 else tmp3148)
tmp3146 = (tmp3094 if depth5 else tmp3147)
tmp3149 = (tmp3146 if depth4 else tmp3147)
tmp3145 = (tmp3146 if depth3 else tmp3149)
tmp3154 = (tmp3094 if depth7 else tmp3135)
tmp3153 = (tmp3094 if depth6 else tmp3154)
tmp3152 = (tmp3153 if depth5 else tmp3147)
tmp3151 = (tmp3146 if depth4 else tmp3152)
tmp3150 = (tmp3151 if depth3 else tmp3149)
tmp3144 = (tmp3145 if depth2 else tmp3150)
tmp3161 = (tmp3094 if k1 else tmp3135)
tmp3160 = (tmp3094 if depth7 else tmp3161)
tmp3159 = (tmp3094 if depth6 else tmp3160)
tmp3158 = (tmp3159 if depth5 else tmp3147)
tmp3157 = (tmp3146 if depth4 else tmp3158)
tmp3156 = (tmp3157 if depth3 else tmp3149)
tmp3167 = (tmp3135 if k1 else tmp3100)
tmp3166 = (tmp3094 if depth7 else tmp3167)
tmp3165 = (tmp3094 if depth6 else tmp3166)
tmp3164 = (tmp3165 if depth5 else tmp3147)
tmp3163 = (tmp3146 if depth4 else tmp3164)
tmp3162 = (tmp3163 if depth3 else tmp3149)
tmp3155 = (tmp3156 if depth2 else tmp3162)
tmp3143 = (tmp3144 if depth1 else tmp3155)
tmp3119 = (tmp3120 if s0 else tmp3143)
tmp3171 = (tmp3146 if depth3 else tmp3163)
tmp3170 = (tmp3171 if depth2 else tmp3156)
tmp3169 = (tmp3170 if depth1 else tmp3144)
tmp3174 = (tmp3146 if depth3 else tmp3151)
tmp3173 = (tmp3174 if depth2 else tmp3145)
tmp3172 = (tmp3173 if depth1 else tmp3170)
tmp3168 = (tmp3169 if s0 else tmp3172)
tmp3118 = (tmp3119 if s1 else tmp3168)
tmp3179 = (tmp3146 if depth3 else tmp3157)
tmp3178 = (tmp3179 if depth2 else tmp3171)
tmp3177 = (tmp3178 if depth1 else tmp3173)
tmp3181 = (tmp3146 if depth2 else tmp3174)
tmp3180 = (tmp3181 if depth1 else tmp3178)
tmp3176 = (tmp3177 if s0 else tmp3180)
tmp3187 = (tmp3094 if depth5 else tmp3165)
tmp3186 = (tmp3187 if depth4 else tmp3146)
tmp3185 = (tmp3186 if depth3 else tmp3146)
tmp3184 = (tmp3185 if depth2 else tmp3179)
tmp3183 = (tmp3184 if depth1 else tmp3181)
tmp3192 = (tmp3094 if depth5 else tmp3153)
tmp3191 = (tmp3192 if depth4 else tmp3146)
tmp3190 = (tmp3191 if depth3 else tmp3146)
tmp3189 = (tmp3190 if depth2 else tmp3146)
tmp3188 = (tmp3189 if depth1 else tmp3184)
tmp3182 = (tmp3183 if s0 else tmp3188)
tmp3175 = (tmp3176 if s1 else tmp3182)
tmp3117 = (tmp3118 if s2 else tmp3175)
tmp3084 = (tmp3085 if s3 else tmp3117)
tmp3201 = (tmp3094 if depth5 else tmp3159)
tmp3200 = (tmp3201 if depth4 else tmp3146)
tmp3199 = (tmp3200 if depth3 else tmp3146)
tmp3198 = (tmp3199 if depth2 else tmp3185)
tmp3197 = (tmp3198 if depth1 else tmp3189)
tmp3205 = (tmp3094 if depth4 else tmp3146)
tmp3204 = (tmp3205 if depth3 else tmp3146)
tmp3203 = (tmp3204 if depth2 else tmp3190)
tmp3202 = (tmp3203 if depth1 else tmp3198)
tmp3196 = (tmp3197 if s0 else tmp3202)
tmp3209 = (tmp3205 if depth3 else tmp3186)
tmp3208 = (tmp3209 if depth2 else tmp3199)
tmp3207 = (tmp3208 if depth1 else tmp3203)
tmp3212 = (tmp3205 if depth3 else tmp3191)
tmp3211 = (tmp3212 if depth2 else tmp3204)
tmp3210 = (tmp3211 if depth1 else tmp3208)
tmp3206 = (tmp3207 if s0 else tmp3210)
tmp3195 = (tmp3196 if s1 else tmp3206)
tmp3217 = (tmp3205 if depth3 else tmp3200)
tmp3216 = (tmp3217 if depth2 else tmp3209)
tmp3215 = (tmp3216 if depth1 else tmp3211)
tmp3219 = (tmp3205 if depth2 else tmp3212)
tmp3218 = (tmp3219 if depth1 else tmp3216)
tmp3214 = (tmp3215 if s0 else tmp3218)
tmp3224 = (tmp3094 if depth4 else tmp3187)
tmp3223 = (tmp3224 if depth3 else tmp3205)
tmp3222 = (tmp3223 if depth2 else tmp3217)
tmp3221 = (tmp3222 if depth1 else tmp3219)
tmp3228 = (tmp3094 if depth4 else tmp3192)
tmp3227 = (tmp3228 if depth3 else tmp3205)
tmp3226 = (tmp3227 if depth2 else tmp3205)
tmp3225 = (tmp3226 if depth1 else tmp3222)
tmp3220 = (tmp3221 if s0 else tmp3225)
tmp3213 = (tmp3214 if s1 else tmp3220)
tmp3194 = (tmp3195 if s2 else tmp3213)
tmp3235 = (tmp3094 if depth4 else tmp3201)
tmp3234 = (tmp3235 if depth3 else tmp3205)
tmp3233 = (tmp3234 if depth2 else tmp3223)
tmp3232 = (tmp3233 if depth1 else tmp3226)
tmp3238 = (tmp3094 if depth3 else tmp3205)
tmp3237 = (tmp3238 if depth2 else tmp3227)
tmp3236 = (tmp3237 if depth1 else tmp3233)
tmp3231 = (tmp3232 if s0 else tmp3236)
tmp3242 = (tmp3094 if depth3 else tmp3224)
tmp3241 = (tmp3242 if depth2 else tmp3234)
tmp3240 = (tmp3241 if depth1 else tmp3237)
tmp3245 = (tmp3094 if depth3 else tmp3228)
tmp3244 = (tmp3245 if depth2 else tmp3238)
tmp3243 = (tmp3244 if depth1 else tmp3241)
tmp3239 = (tmp3240 if s0 else tmp3243)
tmp3230 = (tmp3231 if s1 else tmp3239)
tmp3250 = (tmp3094 if depth3 else tmp3235)
tmp3249 = (tmp3250 if depth2 else tmp3242)
tmp3248 = (tmp3249 if depth1 else tmp3244)
tmp3252 = (tmp3094 if depth2 else tmp3245)
tmp3251 = (tmp3252 if depth1 else tmp3249)
tmp3247 = (tmp3248 if s0 else tmp3251)
tmp3255 = (tmp3094 if depth2 else tmp3250)
tmp3254 = (tmp3255 if depth1 else tmp3252)
tmp3256 = (tmp3094 if depth1 else tmp3255)
tmp3253 = (tmp3254 if s0 else tmp3256)
tmp3246 = (tmp3247 if s1 else tmp3253)
tmp3229 = (tmp3230 if s2 else tmp3246)
tmp3193 = (tmp3194 if s3 else tmp3229)
tmp3083 = (tmp3084 if s4 else tmp3193)
tmp3082 = (tmp2853 if s5 else tmp3083)
tmp2857 = (tmp2858 if s6 else tmp3082)
tmp2843 = (tmp2844 if s7 else tmp2857)
s6n = tmp2843
tmp3266 = (1 if oxygen_full else 0)
tmp3265 = (tmp3266 if k2 else 1)
tmp3264 = (tmp3265 if k1 else 1)
tmp3263 = (tmp3264 if s0 else tmp3265)
tmp3262 = (1 if s1 else tmp3263)
tmp3269 = (tmp3266 if k1 else tmp3265)
tmp3268 = (tmp3269 if s0 else tmp3266)
tmp3267 = (tmp3268 if s1 else tmp3266)
tmp3261 = (tmp3262 if s2 else tmp3267)
tmp3260 = (tmp3261 if s3 else tmp3266)
tmp3259 = (1 if s4 else tmp3260)
tmp3277 = (1 if k2 else tmp3266)
tmp3276 = (tmp3277 if k1 else tmp3266)
tmp3275 = (tmp3276 if s0 else tmp3277)
tmp3274 = (tmp3266 if s1 else tmp3275)
tmp3280 = (1 if k1 else tmp3277)
tmp3279 = (tmp3280 if s0 else 1)
tmp3278 = (tmp3279 if s1 else 1)
tmp3273 = (tmp3274 if s2 else tmp3278)
tmp3272 = (tmp3273 if s3 else 1)
tmp3271 = (tmp3266 if s4 else tmp3272)
tmp3270 = (tmp3271 if s5 else tmp3259)
tmp3258 = (tmp3259 if s6 else tmp3270)
tmp3297 = (1 if action1_1 else 0)
tmp3296 = (1 if action2_1 else tmp3297)
tmp3295 = (1 if action3_1 else tmp3296)
tmp3294 = (tmp3295 if action4_1 else 0)
tmp3302 = (1 - (1 if action1_1 else 0))
tmp3301 = (tmp3297 if action2_1 else tmp3302)
tmp3303 = (1 if action2_1 else tmp3302)
tmp3300 = (tmp3301 if action3_1 else tmp3303)
tmp3299 = (1 if action4_1 else tmp3300)
tmp3298 = (tmp3299 if oxygen_low else tmp3294)
tmp3293 = (tmp3294 if oxygen_full else tmp3298)
tmp3292 = (tmp3293 if depth7 else tmp3294)
tmp3291 = (tmp3292 if depth6 else tmp3294)
tmp3307 = (tmp3293 if k2 else tmp3294)
tmp3306 = (tmp3307 if depth7 else tmp3294)
tmp3305 = (tmp3306 if depth6 else tmp3294)
tmp3304 = (tmp3291 if depth5 else tmp3305)
tmp3290 = (tmp3291 if depth4 else tmp3304)
tmp3316 = (1 - (tmp3301 if action3_1 else tmp3303))
tmp3315 = (tmp3295 if action4_1 else tmp3316)
tmp3314 = (tmp3294 if oxygen_low else tmp3315)
tmp3313 = (tmp3294 if oxygen_full else tmp3314)
tmp3312 = (tmp3294 if diver_found else tmp3313)
tmp3311 = (tmp3294 if depth7 else tmp3312)
tmp3310 = (tmp3294 if depth6 else tmp3311)
tmp3309 = (tmp3291 if depth5 else tmp3310)
tmp3308 = (tmp3291 if depth4 else tmp3309)
tmp3289 = (tmp3290 if depth3 else tmp3308)
tmp3319 = (tmp3291 if depth5 else tmp3294)
tmp3318 = (tmp3291 if depth4 else tmp3319)
tmp3317 = (tmp3318 if depth3 else tmp3308)
tmp3288 = (tmp3289 if depth2 else tmp3317)
tmp3326 = (tmp3307 if k1 else tmp3294)
tmp3325 = (tmp3326 if depth7 else tmp3294)
tmp3324 = (tmp3325 if depth6 else tmp3294)
tmp3323 = (tmp3291 if depth5 else tmp3324)
tmp3322 = (tmp3291 if depth4 else tmp3323)
tmp3321 = (tmp3322 if depth3 else tmp3308)
tmp3332 = (tmp3293 if k1 else tmp3307)
tmp3331 = (tmp3332 if depth7 else tmp3294)
tmp3330 = (tmp3331 if depth6 else tmp3294)
tmp3329 = (tmp3291 if depth5 else tmp3330)
tmp3328 = (tmp3329 if depth4 else tmp3309)
tmp3327 = (tmp3308 if depth3 else tmp3328)
tmp3320 = (tmp3321 if depth2 else tmp3327)
tmp3287 = (1 - (tmp3288 if depth1 else tmp3320))
tmp3286 = (tmp3266 if s1 else tmp3287)
tmp3285 = (tmp3266 if s2 else tmp3286)
tmp3342 = (tmp3294 if oxygen_full else tmp3299)
tmp3341 = (tmp3342 if depth7 else tmp3294)
tmp3340 = (tmp3341 if depth6 else tmp3294)
tmp3347 = (tmp3342 if k2 else tmp3294)
tmp3346 = (tmp3342 if k1 else tmp3347)
tmp3345 = (tmp3346 if depth7 else tmp3294)
tmp3344 = (tmp3345 if depth6 else tmp3294)
tmp3343 = (tmp3340 if depth5 else tmp3344)
tmp3339 = (tmp3340 if depth4 else tmp3343)
tmp3349 = (tmp3340 if depth5 else tmp3294)
tmp3348 = (tmp3340 if depth4 else tmp3349)
tmp3338 = (tmp3339 if depth3 else tmp3348)
tmp3355 = (tmp3347 if k1 else tmp3294)
tmp3354 = (tmp3355 if depth7 else tmp3294)
tmp3353 = (tmp3354 if depth6 else tmp3294)
tmp3352 = (tmp3340 if depth5 else tmp3353)
tmp3351 = (tmp3340 if depth4 else tmp3352)
tmp3350 = (tmp3351 if depth3 else tmp3348)
tmp3337 = (tmp3338 if depth2 else tmp3350)
tmp3361 = (tmp3347 if depth7 else tmp3294)
tmp3360 = (tmp3361 if depth6 else tmp3294)
tmp3359 = (tmp3340 if depth5 else tmp3360)
tmp3358 = (tmp3340 if depth4 else tmp3359)
tmp3357 = (tmp3358 if depth3 else tmp3348)
tmp3356 = (tmp3357 if depth2 else tmp3348)
tmp3336 = (tmp3337 if depth1 else tmp3356)
tmp3364 = (tmp3340 if depth3 else tmp3348)
tmp3363 = (tmp3364 if depth2 else tmp3357)
tmp3362 = (tmp3363 if depth1 else tmp3337)
tmp3335 = (tmp3336 if s0 else tmp3362)
tmp3368 = (tmp3340 if depth3 else tmp3351)
tmp3367 = (tmp3368 if depth2 else tmp3338)
tmp3366 = (tmp3367 if depth1 else tmp3363)
tmp3371 = (tmp3340 if depth3 else tmp3358)
tmp3370 = (tmp3371 if depth2 else tmp3364)
tmp3369 = (tmp3370 if depth1 else tmp3367)
tmp3365 = (tmp3366 if s0 else tmp3369)
tmp3334 = (tmp3335 if s1 else tmp3365)
tmp3381 = (tmp3294 if oxygen_full else 1)
tmp3380 = (tmp3381 if k2 else tmp3342)
tmp3379 = (tmp3380 if k1 else tmp3342)
tmp3383 = (tmp3381 if k2 else tmp3294)
tmp3382 = (tmp3383 if k1 else tmp3294)
tmp3378 = (tmp3379 if depth7 else tmp3382)
tmp3377 = (tmp3378 if depth6 else tmp3382)
tmp3388 = (tmp3380 if k1 else tmp3347)
tmp3387 = (tmp3388 if depth7 else tmp3382)
tmp3386 = (tmp3387 if depth6 else tmp3382)
tmp3385 = (tmp3377 if depth5 else tmp3386)
tmp3384 = (tmp3377 if depth4 else tmp3385)
tmp3376 = (tmp3377 if depth3 else tmp3384)
tmp3391 = (tmp3377 if depth5 else tmp3382)
tmp3390 = (tmp3377 if depth4 else tmp3391)
tmp3389 = (tmp3377 if depth3 else tmp3390)
tmp3375 = (tmp3376 if depth2 else tmp3389)
tmp3398 = (tmp3383 if k1 else tmp3347)
tmp3397 = (tmp3398 if depth7 else tmp3382)
tmp3396 = (tmp3397 if depth6 else tmp3382)
tmp3395 = (tmp3377 if depth5 else tmp3396)
tmp3394 = (tmp3377 if depth4 else tmp3395)
tmp3393 = (tmp3377 if depth3 else tmp3394)
tmp3392 = (tmp3393 if depth2 else tmp3389)
tmp3374 = (tmp3375 if depth1 else tmp3392)
tmp3402 = (tmp3380 if depth7 else tmp3383)
tmp3401 = (tmp3402 if depth6 else tmp3383)
tmp3405 = (tmp3401 if depth5 else tmp3383)
tmp3404 = (tmp3401 if depth4 else tmp3405)
tmp3403 = (tmp3401 if depth3 else tmp3404)
tmp3400 = (tmp3401 if depth2 else tmp3403)
tmp3412 = (tmp3380 if k1 else tmp3383)
tmp3411 = (tmp3412 if depth7 else tmp3383)
tmp3410 = (tmp3411 if depth6 else tmp3383)
tmp3409 = (tmp3401 if depth5 else tmp3410)
tmp3408 = (tmp3401 if depth4 else tmp3409)
tmp3407 = (tmp3401 if depth3 else tmp3408)
tmp3406 = (tmp3407 if depth2 else tmp3403)
tmp3399 = (tmp3400 if depth1 else tmp3406)
tmp3373 = (tmp3374 if s0 else tmp3399)
tmp3417 = (tmp3381 if k1 else tmp3380)
tmp3418 = (tmp3381 if k1 else tmp3383)
tmp3416 = (tmp3417 if depth7 else tmp3418)
tmp3415 = (tmp3416 if depth6 else tmp3418)
tmp3421 = (tmp3415 if depth5 else tmp3418)
tmp3420 = (tmp3415 if depth4 else tmp3421)
tmp3419 = (tmp3415 if depth3 else tmp3420)
tmp3414 = (tmp3415 if depth2 else tmp3419)
tmp3413 = (tmp3414 if s0 else tmp3381)
tmp3372 = (tmp3373 if s1 else tmp3413)
tmp3333 = (1 - (tmp3334 if s2 else tmp3372))
tmp3284 = (tmp3285 if s3 else tmp3333)
tmp3283 = (tmp3266 if s4 else tmp3284)
tmp3435 = (1 - (1 if action4_1 else tmp3300))
tmp3434 = (tmp3294 if oxygen_full else tmp3435)
tmp3433 = (tmp3434 if k2 else tmp3381)
tmp3432 = (tmp3433 if k1 else tmp3381)
tmp3439 = (1 - (tmp3295 if action4_1 else 0))
tmp3438 = (tmp3294 if oxygen_full else tmp3439)
tmp3437 = (tmp3438 if k2 else tmp3381)
tmp3436 = (tmp3437 if k1 else tmp3381)
tmp3431 = (tmp3432 if depth7 else tmp3436)
tmp3440 = (tmp3431 if depth6 else tmp3436)
tmp3430 = (tmp3431 if depth5 else tmp3440)
tmp3441 = (tmp3430 if depth4 else tmp3440)
tmp3429 = (tmp3430 if depth3 else tmp3441)
tmp3428 = (tmp3429 if depth2 else tmp3441)
tmp3427 = (tmp3428 if depth1 else tmp3441)
tmp3446 = (tmp3433 if depth7 else tmp3437)
tmp3447 = (tmp3446 if depth6 else tmp3437)
tmp3445 = (tmp3446 if depth5 else tmp3447)
tmp3448 = (tmp3445 if depth4 else tmp3447)
tmp3444 = (tmp3445 if depth3 else tmp3448)
tmp3443 = (tmp3444 if depth2 else tmp3448)
tmp3455 = (tmp3433 if k1 else tmp3437)
tmp3454 = (tmp3455 if depth7 else tmp3437)
tmp3453 = (tmp3446 if depth6 else tmp3454)
tmp3452 = (tmp3453 if depth5 else tmp3447)
tmp3451 = (tmp3445 if depth4 else tmp3452)
tmp3450 = (tmp3451 if depth3 else tmp3448)
tmp3449 = (tmp3450 if depth2 else tmp3448)
tmp3442 = (tmp3443 if depth1 else tmp3449)
tmp3426 = (tmp3427 if s0 else tmp3442)
tmp3425 = (tmp3381 if s1 else tmp3426)
tmp3424 = (tmp3381 if s2 else tmp3425)
tmp3464 = (tmp3434 if k1 else tmp3433)
tmp3465 = (tmp3438 if k1 else tmp3437)
tmp3463 = (tmp3464 if depth7 else tmp3465)
tmp3466 = (tmp3463 if depth6 else tmp3465)
tmp3462 = (tmp3463 if depth5 else tmp3466)
tmp3467 = (tmp3462 if depth4 else tmp3466)
tmp3461 = (tmp3462 if depth3 else tmp3467)
tmp3474 = (tmp3434 if k2 else tmp3438)
tmp3473 = (tmp3474 if k1 else tmp3437)
tmp3472 = (tmp3473 if depth7 else tmp3465)
tmp3471 = (tmp3463 if depth6 else tmp3472)
tmp3470 = (tmp3471 if depth5 else tmp3466)
tmp3469 = (tmp3462 if depth4 else tmp3470)
tmp3468 = (tmp3469 if depth3 else tmp3467)
tmp3460 = (tmp3461 if depth2 else tmp3468)
tmp3481 = (tmp3474 if k1 else tmp3433)
tmp3480 = (tmp3481 if depth7 else tmp3465)
tmp3479 = (tmp3463 if depth6 else tmp3480)
tmp3478 = (tmp3479 if depth5 else tmp3466)
tmp3477 = (tmp3462 if depth4 else tmp3478)
tmp3476 = (tmp3477 if depth3 else tmp3467)
tmp3475 = (tmp3476 if depth2 else tmp3467)
tmp3459 = (tmp3460 if depth1 else tmp3475)
tmp3486 = (tmp3434 if depth7 else tmp3438)
tmp3487 = (tmp3486 if depth6 else tmp3438)
tmp3485 = (tmp3486 if depth5 else tmp3487)
tmp3488 = (tmp3485 if depth4 else tmp3487)
tmp3484 = (tmp3485 if depth3 else tmp3488)
tmp3493 = (tmp3474 if depth7 else tmp3438)
tmp3492 = (tmp3486 if depth6 else tmp3493)
tmp3491 = (tmp3492 if depth5 else tmp3487)
tmp3490 = (tmp3485 if depth4 else tmp3491)
tmp3489 = (tmp3490 if depth3 else tmp3488)
tmp3483 = (tmp3484 if depth2 else tmp3489)
tmp3500 = (tmp3434 if k1 else tmp3474)
tmp3499 = (tmp3500 if depth7 else tmp3438)
tmp3498 = (tmp3486 if depth6 else tmp3499)
tmp3497 = (tmp3498 if depth5 else tmp3487)
tmp3496 = (tmp3485 if depth4 else tmp3497)
tmp3495 = (tmp3496 if depth3 else tmp3488)
tmp3506 = (tmp3474 if k1 else tmp3438)
tmp3505 = (tmp3506 if depth7 else tmp3438)
tmp3504 = (tmp3486 if depth6 else tmp3505)
tmp3503 = (tmp3504 if depth5 else tmp3487)
tmp3502 = (tmp3485 if depth4 else tmp3503)
tmp3501 = (tmp3502 if depth3 else tmp3488)
tmp3494 = (tmp3495 if depth2 else tmp3501)
tmp3482 = (tmp3483 if depth1 else tmp3494)
tmp3458 = (tmp3459 if s0 else tmp3482)
tmp3510 = (tmp3485 if depth3 else tmp3502)
tmp3509 = (tmp3510 if depth2 else tmp3495)
tmp3508 = (tmp3509 if depth1 else tmp3483)
tmp3513 = (tmp3485 if depth3 else tmp3490)
tmp3512 = (tmp3513 if depth2 else tmp3484)
tmp3511 = (tmp3512 if depth1 else tmp3509)
tmp3507 = (tmp3508 if s0 else tmp3511)
tmp3457 = (tmp3458 if s1 else tmp3507)
tmp3518 = (tmp3485 if depth3 else tmp3496)
tmp3517 = (tmp3518 if depth2 else tmp3510)
tmp3516 = (tmp3517 if depth1 else tmp3512)
tmp3520 = (tmp3485 if depth2 else tmp3513)
tmp3519 = (tmp3520 if depth1 else tmp3517)
tmp3515 = (tmp3516 if s0 else tmp3519)
tmp3526 = (tmp3486 if depth5 else tmp3504)
tmp3525 = (tmp3526 if depth4 else tmp3485)
tmp3524 = (tmp3525 if depth3 else tmp3485)
tmp3523 = (tmp3524 if depth2 else tmp3518)
tmp3522 = (tmp3523 if depth1 else tmp3520)
tmp3531 = (tmp3486 if depth5 else tmp3492)
tmp3530 = (tmp3531 if depth4 else tmp3485)
tmp3529 = (tmp3530 if depth3 else tmp3485)
tmp3528 = (tmp3529 if depth2 else tmp3485)
tmp3527 = (tmp3528 if depth1 else tmp3523)
tmp3521 = (tmp3522 if s0 else tmp3527)
tmp3514 = (tmp3515 if s1 else tmp3521)
tmp3456 = (tmp3457 if s2 else tmp3514)
tmp3423 = (tmp3424 if s3 else tmp3456)
tmp3540 = (tmp3486 if depth5 else tmp3498)
tmp3539 = (tmp3540 if depth4 else tmp3485)
tmp3538 = (tmp3539 if depth3 else tmp3485)
tmp3537 = (tmp3538 if depth2 else tmp3524)
tmp3536 = (tmp3537 if depth1 else tmp3528)
tmp3544 = (tmp3486 if depth4 else tmp3485)
tmp3543 = (tmp3544 if depth3 else tmp3485)
tmp3542 = (tmp3543 if depth2 else tmp3529)
tmp3541 = (tmp3542 if depth1 else tmp3537)
tmp3535 = (tmp3536 if s0 else tmp3541)
tmp3548 = (tmp3544 if depth3 else tmp3525)
tmp3547 = (tmp3548 if depth2 else tmp3538)
tmp3546 = (tmp3547 if depth1 else tmp3542)
tmp3551 = (tmp3544 if depth3 else tmp3530)
tmp3550 = (tmp3551 if depth2 else tmp3543)
tmp3549 = (tmp3550 if depth1 else tmp3547)
tmp3545 = (tmp3546 if s0 else tmp3549)
tmp3534 = (tmp3535 if s1 else tmp3545)
tmp3556 = (tmp3544 if depth3 else tmp3539)
tmp3555 = (tmp3556 if depth2 else tmp3548)
tmp3554 = (tmp3555 if depth1 else tmp3550)
tmp3558 = (tmp3544 if depth2 else tmp3551)
tmp3557 = (tmp3558 if depth1 else tmp3555)
tmp3553 = (tmp3554 if s0 else tmp3557)
tmp3563 = (tmp3486 if depth4 else tmp3526)
tmp3562 = (tmp3563 if depth3 else tmp3544)
tmp3561 = (tmp3562 if depth2 else tmp3556)
tmp3560 = (tmp3561 if depth1 else tmp3558)
tmp3567 = (tmp3486 if depth4 else tmp3531)
tmp3566 = (tmp3567 if depth3 else tmp3544)
tmp3565 = (tmp3566 if depth2 else tmp3544)
tmp3564 = (tmp3565 if depth1 else tmp3561)
tmp3559 = (tmp3560 if s0 else tmp3564)
tmp3552 = (tmp3553 if s1 else tmp3559)
tmp3533 = (tmp3534 if s2 else tmp3552)
tmp3574 = (tmp3486 if depth4 else tmp3540)
tmp3573 = (tmp3574 if depth3 else tmp3544)
tmp3572 = (tmp3573 if depth2 else tmp3562)
tmp3571 = (tmp3572 if depth1 else tmp3565)
tmp3577 = (tmp3486 if depth3 else tmp3544)
tmp3576 = (tmp3577 if depth2 else tmp3566)
tmp3575 = (tmp3576 if depth1 else tmp3572)
tmp3570 = (tmp3571 if s0 else tmp3575)
tmp3581 = (tmp3486 if depth3 else tmp3563)
tmp3580 = (tmp3581 if depth2 else tmp3573)
tmp3579 = (tmp3580 if depth1 else tmp3576)
tmp3584 = (tmp3486 if depth3 else tmp3567)
tmp3583 = (tmp3584 if depth2 else tmp3577)
tmp3582 = (tmp3583 if depth1 else tmp3580)
tmp3578 = (tmp3579 if s0 else tmp3582)
tmp3569 = (tmp3570 if s1 else tmp3578)
tmp3593 = (tmp3294 if oxygen_full else 0)
tmp3592 = (tmp3593 if k2 else tmp3434)
tmp3591 = (tmp3592 if k1 else tmp3434)
tmp3595 = (tmp3593 if k2 else tmp3438)
tmp3594 = (tmp3595 if k1 else tmp3438)
tmp3590 = (tmp3591 if depth7 else tmp3594)
tmp3600 = (tmp3592 if k1 else tmp3474)
tmp3599 = (tmp3600 if depth7 else tmp3594)
tmp3598 = (tmp3590 if depth6 else tmp3599)
tmp3597 = (tmp3590 if depth5 else tmp3598)
tmp3596 = (tmp3590 if depth4 else tmp3597)
tmp3589 = (tmp3590 if depth3 else tmp3596)
tmp3604 = (tmp3590 if depth6 else tmp3594)
tmp3603 = (tmp3590 if depth5 else tmp3604)
tmp3602 = (tmp3590 if depth4 else tmp3603)
tmp3601 = (tmp3590 if depth3 else tmp3602)
tmp3588 = (tmp3589 if depth2 else tmp3601)
tmp3611 = (tmp3595 if k1 else tmp3474)
tmp3610 = (tmp3611 if depth7 else tmp3594)
tmp3609 = (tmp3590 if depth6 else tmp3610)
tmp3608 = (tmp3590 if depth5 else tmp3609)
tmp3607 = (tmp3590 if depth4 else tmp3608)
tmp3606 = (tmp3590 if depth3 else tmp3607)
tmp3605 = (tmp3606 if depth2 else tmp3601)
tmp3587 = (tmp3588 if depth1 else tmp3605)
tmp3614 = (tmp3592 if depth7 else tmp3595)
tmp3618 = (tmp3614 if depth6 else tmp3595)
tmp3617 = (tmp3614 if depth5 else tmp3618)
tmp3616 = (tmp3614 if depth4 else tmp3617)
tmp3615 = (tmp3614 if depth3 else tmp3616)
tmp3613 = (tmp3614 if depth2 else tmp3615)
tmp3625 = (tmp3592 if k1 else tmp3595)
tmp3624 = (tmp3625 if depth7 else tmp3595)
tmp3623 = (tmp3614 if depth6 else tmp3624)
tmp3622 = (tmp3614 if depth5 else tmp3623)
tmp3621 = (tmp3614 if depth4 else tmp3622)
tmp3620 = (tmp3614 if depth3 else tmp3621)
tmp3619 = (tmp3620 if depth2 else tmp3615)
tmp3612 = (tmp3613 if depth1 else tmp3619)
tmp3586 = (tmp3587 if s0 else tmp3612)
tmp3629 = (tmp3593 if k1 else tmp3592)
tmp3630 = (tmp3593 if k1 else tmp3595)
tmp3628 = (tmp3629 if depth7 else tmp3630)
tmp3634 = (tmp3628 if depth6 else tmp3630)
tmp3633 = (tmp3628 if depth5 else tmp3634)
tmp3632 = (tmp3628 if depth4 else tmp3633)
tmp3631 = (tmp3628 if depth3 else tmp3632)
tmp3627 = (tmp3628 if depth2 else tmp3631)
tmp3626 = (tmp3627 if s0 else tmp3593)
tmp3585 = (tmp3586 if s1 else tmp3626)
tmp3568 = (tmp3569 if s2 else tmp3585)
tmp3532 = (tmp3533 if s3 else tmp3568)
tmp3422 = (1 - (tmp3423 if s4 else tmp3532))
tmp3282 = (tmp3283 if s5 else tmp3422)
tmp3647 = (tmp3342 if k2 else tmp3593)
tmp3646 = (tmp3647 if k1 else tmp3593)
tmp3650 = (tmp3294 if k2 else tmp3593)
tmp3649 = (tmp3650 if k1 else tmp3593)
tmp3648 = (tmp3646 if depth7 else tmp3649)
tmp3645 = (tmp3646 if depth6 else tmp3648)
tmp3644 = (tmp3645 if depth5 else tmp3648)
tmp3651 = (tmp3644 if depth4 else tmp3648)
tmp3643 = (tmp3644 if depth3 else tmp3651)
tmp3642 = (tmp3643 if depth2 else tmp3651)
tmp3641 = (tmp3642 if depth1 else tmp3651)
tmp3657 = (tmp3647 if depth7 else tmp3650)
tmp3656 = (tmp3647 if depth6 else tmp3657)
tmp3655 = (tmp3656 if depth5 else tmp3657)
tmp3658 = (tmp3655 if depth4 else tmp3657)
tmp3654 = (tmp3655 if depth3 else tmp3658)
tmp3653 = (tmp3654 if depth2 else tmp3658)
tmp3665 = (tmp3647 if k1 else tmp3650)
tmp3664 = (tmp3647 if depth7 else tmp3665)
tmp3663 = (tmp3664 if depth6 else tmp3657)
tmp3662 = (tmp3663 if depth5 else tmp3657)
tmp3661 = (tmp3655 if depth4 else tmp3662)
tmp3660 = (tmp3661 if depth3 else tmp3658)
tmp3659 = (tmp3660 if depth2 else tmp3658)
tmp3652 = (tmp3653 if depth1 else tmp3659)
tmp3640 = (tmp3641 if s0 else tmp3652)
tmp3639 = (tmp3593 if s1 else tmp3640)
tmp3638 = (tmp3593 if s2 else tmp3639)
tmp3674 = (tmp3342 if k1 else tmp3647)
tmp3676 = (tmp3294 if k1 else tmp3650)
tmp3675 = (tmp3674 if depth7 else tmp3676)
tmp3673 = (tmp3674 if depth6 else tmp3675)
tmp3672 = (tmp3673 if depth5 else tmp3675)
tmp3677 = (tmp3672 if depth4 else tmp3675)
tmp3671 = (tmp3672 if depth3 else tmp3677)
tmp3683 = (tmp3347 if k1 else tmp3650)
tmp3682 = (tmp3674 if depth7 else tmp3683)
tmp3681 = (tmp3682 if depth6 else tmp3675)
tmp3680 = (tmp3681 if depth5 else tmp3675)
tmp3679 = (tmp3672 if depth4 else tmp3680)
tmp3678 = (tmp3679 if depth3 else tmp3677)
tmp3670 = (tmp3671 if depth2 else tmp3678)
tmp3690 = (tmp3347 if k1 else tmp3647)
tmp3689 = (tmp3674 if depth7 else tmp3690)
tmp3688 = (tmp3689 if depth6 else tmp3675)
tmp3687 = (tmp3688 if depth5 else tmp3675)
tmp3686 = (tmp3672 if depth4 else tmp3687)
tmp3685 = (tmp3686 if depth3 else tmp3677)
tmp3684 = (tmp3685 if depth2 else tmp3677)
tmp3669 = (tmp3670 if depth1 else tmp3684)
tmp3695 = (tmp3342 if depth6 else tmp3341)
tmp3694 = (tmp3695 if depth5 else tmp3341)
tmp3696 = (tmp3694 if depth4 else tmp3341)
tmp3693 = (tmp3694 if depth3 else tmp3696)
tmp3701 = (tmp3342 if depth7 else tmp3347)
tmp3700 = (tmp3701 if depth6 else tmp3341)
tmp3699 = (tmp3700 if depth5 else tmp3341)
tmp3698 = (tmp3694 if depth4 else tmp3699)
tmp3697 = (tmp3698 if depth3 else tmp3696)
tmp3692 = (tmp3693 if depth2 else tmp3697)
tmp3707 = (tmp3342 if depth7 else tmp3346)
tmp3706 = (tmp3707 if depth6 else tmp3341)
tmp3705 = (tmp3706 if depth5 else tmp3341)
tmp3704 = (tmp3694 if depth4 else tmp3705)
tmp3703 = (tmp3704 if depth3 else tmp3696)
tmp3712 = (tmp3342 if depth7 else tmp3355)
tmp3711 = (tmp3712 if depth6 else tmp3341)
tmp3710 = (tmp3711 if depth5 else tmp3341)
tmp3709 = (tmp3694 if depth4 else tmp3710)
tmp3708 = (tmp3709 if depth3 else tmp3696)
tmp3702 = (tmp3703 if depth2 else tmp3708)
tmp3691 = (tmp3692 if depth1 else tmp3702)
tmp3668 = (tmp3669 if s0 else tmp3691)
tmp3716 = (tmp3694 if depth3 else tmp3709)
tmp3715 = (tmp3716 if depth2 else tmp3703)
tmp3714 = (tmp3715 if depth1 else tmp3692)
tmp3719 = (tmp3694 if depth3 else tmp3698)
tmp3718 = (tmp3719 if depth2 else tmp3693)
tmp3717 = (tmp3718 if depth1 else tmp3715)
tmp3713 = (tmp3714 if s0 else tmp3717)
tmp3667 = (tmp3668 if s1 else tmp3713)
tmp3724 = (tmp3694 if depth3 else tmp3704)
tmp3723 = (tmp3724 if depth2 else tmp3716)
tmp3722 = (tmp3723 if depth1 else tmp3718)
tmp3726 = (tmp3694 if depth2 else tmp3719)
tmp3725 = (tmp3726 if depth1 else tmp3723)
tmp3721 = (tmp3722 if s0 else tmp3725)
tmp3732 = (tmp3695 if depth5 else tmp3711)
tmp3731 = (tmp3732 if depth4 else tmp3694)
tmp3730 = (tmp3731 if depth3 else tmp3694)
tmp3729 = (tmp3730 if depth2 else tmp3724)
tmp3728 = (tmp3729 if depth1 else tmp3726)
tmp3737 = (tmp3695 if depth5 else tmp3700)
tmp3736 = (tmp3737 if depth4 else tmp3694)
tmp3735 = (tmp3736 if depth3 else tmp3694)
tmp3734 = (tmp3735 if depth2 else tmp3694)
tmp3733 = (tmp3734 if depth1 else tmp3729)
tmp3727 = (tmp3728 if s0 else tmp3733)
tmp3720 = (tmp3721 if s1 else tmp3727)
tmp3666 = (tmp3667 if s2 else tmp3720)
tmp3637 = (tmp3638 if s3 else tmp3666)
tmp3746 = (tmp3695 if depth5 else tmp3706)
tmp3745 = (tmp3746 if depth4 else tmp3694)
tmp3744 = (tmp3745 if depth3 else tmp3694)
tmp3743 = (tmp3744 if depth2 else tmp3730)
tmp3742 = (tmp3743 if depth1 else tmp3734)
tmp3750 = (tmp3695 if depth4 else tmp3694)
tmp3749 = (tmp3750 if depth3 else tmp3694)
tmp3748 = (tmp3749 if depth2 else tmp3735)
tmp3747 = (tmp3748 if depth1 else tmp3743)
tmp3741 = (tmp3742 if s0 else tmp3747)
tmp3754 = (tmp3750 if depth3 else tmp3731)
tmp3753 = (tmp3754 if depth2 else tmp3744)
tmp3752 = (tmp3753 if depth1 else tmp3748)
tmp3757 = (tmp3750 if depth3 else tmp3736)
tmp3756 = (tmp3757 if depth2 else tmp3749)
tmp3755 = (tmp3756 if depth1 else tmp3753)
tmp3751 = (tmp3752 if s0 else tmp3755)
tmp3740 = (tmp3741 if s1 else tmp3751)
tmp3762 = (tmp3750 if depth3 else tmp3745)
tmp3761 = (tmp3762 if depth2 else tmp3754)
tmp3760 = (tmp3761 if depth1 else tmp3756)
tmp3764 = (tmp3750 if depth2 else tmp3757)
tmp3763 = (tmp3764 if depth1 else tmp3761)
tmp3759 = (tmp3760 if s0 else tmp3763)
tmp3769 = (tmp3695 if depth4 else tmp3732)
tmp3768 = (tmp3769 if depth3 else tmp3750)
tmp3767 = (tmp3768 if depth2 else tmp3762)
tmp3766 = (tmp3767 if depth1 else tmp3764)
tmp3773 = (tmp3695 if depth4 else tmp3737)
tmp3772 = (tmp3773 if depth3 else tmp3750)
tmp3771 = (tmp3772 if depth2 else tmp3750)
tmp3770 = (tmp3771 if depth1 else tmp3767)
tmp3765 = (tmp3766 if s0 else tmp3770)
tmp3758 = (tmp3759 if s1 else tmp3765)
tmp3739 = (tmp3740 if s2 else tmp3758)
tmp3780 = (tmp3695 if depth4 else tmp3746)
tmp3779 = (tmp3780 if depth3 else tmp3750)
tmp3778 = (tmp3779 if depth2 else tmp3768)
tmp3777 = (tmp3778 if depth1 else tmp3771)
tmp3783 = (tmp3695 if depth3 else tmp3750)
tmp3782 = (tmp3783 if depth2 else tmp3772)
tmp3781 = (tmp3782 if depth1 else tmp3778)
tmp3776 = (tmp3777 if s0 else tmp3781)
tmp3787 = (tmp3695 if depth3 else tmp3769)
tmp3786 = (tmp3787 if depth2 else tmp3779)
tmp3785 = (tmp3786 if depth1 else tmp3782)
tmp3790 = (tmp3695 if depth3 else tmp3773)
tmp3789 = (tmp3790 if depth2 else tmp3783)
tmp3788 = (tmp3789 if depth1 else tmp3786)
tmp3784 = (tmp3785 if s0 else tmp3788)
tmp3775 = (tmp3776 if s1 else tmp3784)
tmp3796 = (tmp3379 if depth6 else tmp3378)
tmp3800 = (tmp3379 if depth7 else tmp3388)
tmp3799 = (tmp3800 if depth6 else tmp3378)
tmp3798 = (tmp3796 if depth5 else tmp3799)
tmp3797 = (tmp3796 if depth4 else tmp3798)
tmp3795 = (tmp3796 if depth3 else tmp3797)
tmp3803 = (tmp3796 if depth5 else tmp3378)
tmp3802 = (tmp3796 if depth4 else tmp3803)
tmp3801 = (tmp3796 if depth3 else tmp3802)
tmp3794 = (tmp3795 if depth2 else tmp3801)
tmp3809 = (tmp3379 if depth7 else tmp3398)
tmp3808 = (tmp3809 if depth6 else tmp3378)
tmp3807 = (tmp3796 if depth5 else tmp3808)
tmp3806 = (tmp3796 if depth4 else tmp3807)
tmp3805 = (tmp3796 if depth3 else tmp3806)
tmp3804 = (tmp3805 if depth2 else tmp3801)
tmp3793 = (tmp3794 if depth1 else tmp3804)
tmp3812 = (tmp3380 if depth6 else tmp3402)
tmp3815 = (tmp3812 if depth5 else tmp3402)
tmp3814 = (tmp3812 if depth4 else tmp3815)
tmp3813 = (tmp3812 if depth3 else tmp3814)
tmp3811 = (tmp3812 if depth2 else tmp3813)
tmp3821 = (tmp3380 if depth7 else tmp3412)
tmp3820 = (tmp3821 if depth6 else tmp3402)
tmp3819 = (tmp3812 if depth5 else tmp3820)
tmp3818 = (tmp3812 if depth4 else tmp3819)
tmp3817 = (tmp3812 if depth3 else tmp3818)
tmp3816 = (tmp3817 if depth2 else tmp3813)
tmp3810 = (tmp3811 if depth1 else tmp3816)
tmp3792 = (tmp3793 if s0 else tmp3810)
tmp3824 = (tmp3417 if depth6 else tmp3416)
tmp3827 = (tmp3824 if depth5 else tmp3416)
tmp3826 = (tmp3824 if depth4 else tmp3827)
tmp3825 = (tmp3824 if depth3 else tmp3826)
tmp3823 = (tmp3824 if depth2 else tmp3825)
tmp3822 = (tmp3823 if s0 else tmp3381)
tmp3791 = (tmp3792 if s1 else tmp3822)
tmp3774 = (tmp3775 if s2 else tmp3791)
tmp3738 = (tmp3739 if s3 else tmp3774)
tmp3636 = (tmp3637 if s4 else tmp3738)
tmp3837 = (tmp3432 if depth6 else tmp3431)
tmp3836 = (tmp3432 if depth5 else tmp3837)
tmp3838 = (tmp3836 if depth4 else tmp3837)
tmp3835 = (tmp3836 if depth3 else tmp3838)
tmp3834 = (tmp3835 if depth2 else tmp3838)
tmp3833 = (tmp3834 if depth1 else tmp3838)
tmp3843 = (tmp3433 if depth6 else tmp3446)
tmp3842 = (tmp3433 if depth5 else tmp3843)
tmp3844 = (tmp3842 if depth4 else tmp3843)
tmp3841 = (tmp3842 if depth3 else tmp3844)
tmp3840 = (tmp3841 if depth2 else tmp3844)
tmp3850 = (tmp3433 if depth7 else tmp3455)
tmp3849 = (tmp3433 if depth6 else tmp3850)
tmp3848 = (tmp3849 if depth5 else tmp3843)
tmp3847 = (tmp3842 if depth4 else tmp3848)
tmp3846 = (tmp3847 if depth3 else tmp3844)
tmp3845 = (tmp3846 if depth2 else tmp3844)
tmp3839 = (tmp3840 if depth1 else tmp3845)
tmp3832 = (tmp3833 if s0 else tmp3839)
tmp3831 = (tmp3381 if s1 else tmp3832)
tmp3830 = (tmp3381 if s2 else tmp3831)
tmp3858 = (tmp3464 if depth6 else tmp3463)
tmp3857 = (tmp3464 if depth5 else tmp3858)
tmp3859 = (tmp3857 if depth4 else tmp3858)
tmp3856 = (tmp3857 if depth3 else tmp3859)
tmp3864 = (tmp3464 if depth7 else tmp3473)
tmp3863 = (tmp3464 if depth6 else tmp3864)
tmp3862 = (tmp3863 if depth5 else tmp3858)
tmp3861 = (tmp3857 if depth4 else tmp3862)
tmp3860 = (tmp3861 if depth3 else tmp3859)
tmp3855 = (tmp3856 if depth2 else tmp3860)
tmp3870 = (tmp3464 if depth7 else tmp3481)
tmp3869 = (tmp3464 if depth6 else tmp3870)
tmp3868 = (tmp3869 if depth5 else tmp3858)
tmp3867 = (tmp3857 if depth4 else tmp3868)
tmp3866 = (tmp3867 if depth3 else tmp3859)
tmp3865 = (tmp3866 if depth2 else tmp3859)
tmp3854 = (tmp3855 if depth1 else tmp3865)
tmp3875 = (tmp3434 if depth6 else tmp3486)
tmp3874 = (tmp3434 if depth5 else tmp3875)
tmp3876 = (tmp3874 if depth4 else tmp3875)
tmp3873 = (tmp3874 if depth3 else tmp3876)
tmp3881 = (tmp3434 if depth7 else tmp3474)
tmp3880 = (tmp3434 if depth6 else tmp3881)
tmp3879 = (tmp3880 if depth5 else tmp3875)
tmp3878 = (tmp3874 if depth4 else tmp3879)
tmp3877 = (tmp3878 if depth3 else tmp3876)
tmp3872 = (tmp3873 if depth2 else tmp3877)
tmp3887 = (tmp3434 if depth7 else tmp3500)
tmp3886 = (tmp3434 if depth6 else tmp3887)
tmp3885 = (tmp3886 if depth5 else tmp3875)
tmp3884 = (tmp3874 if depth4 else tmp3885)
tmp3883 = (tmp3884 if depth3 else tmp3876)
tmp3892 = (tmp3434 if depth7 else tmp3506)
tmp3891 = (tmp3434 if depth6 else tmp3892)
tmp3890 = (tmp3891 if depth5 else tmp3875)
tmp3889 = (tmp3874 if depth4 else tmp3890)
tmp3888 = (tmp3889 if depth3 else tmp3876)
tmp3882 = (tmp3883 if depth2 else tmp3888)
tmp3871 = (tmp3872 if depth1 else tmp3882)
tmp3853 = (tmp3854 if s0 else tmp3871)
tmp3896 = (tmp3874 if depth3 else tmp3889)
tmp3895 = (tmp3896 if depth2 else tmp3883)
tmp3894 = (tmp3895 if depth1 else tmp3872)
tmp3899 = (tmp3874 if depth3 else tmp3878)
tmp3898 = (tmp3899 if depth2 else tmp3873)
tmp3897 = (tmp3898 if depth1 else tmp3895)
tmp3893 = (tmp3894 if s0 else tmp3897)
tmp3852 = (tmp3853 if s1 else tmp3893)
tmp3904 = (tmp3874 if depth3 else tmp3884)
tmp3903 = (tmp3904 if depth2 else tmp3896)
tmp3902 = (tmp3903 if depth1 else tmp3898)
tmp3906 = (tmp3874 if depth2 else tmp3899)
tmp3905 = (tmp3906 if depth1 else tmp3903)
tmp3901 = (tmp3902 if s0 else tmp3905)
tmp3912 = (tmp3434 if depth5 else tmp3891)
tmp3911 = (tmp3912 if depth4 else tmp3874)
tmp3910 = (tmp3911 if depth3 else tmp3874)
tmp3909 = (tmp3910 if depth2 else tmp3904)
tmp3908 = (tmp3909 if depth1 else tmp3906)
tmp3917 = (tmp3434 if depth5 else tmp3880)
tmp3916 = (tmp3917 if depth4 else tmp3874)
tmp3915 = (tmp3916 if depth3 else tmp3874)
tmp3914 = (tmp3915 if depth2 else tmp3874)
tmp3913 = (tmp3914 if depth1 else tmp3909)
tmp3907 = (tmp3908 if s0 else tmp3913)
tmp3900 = (tmp3901 if s1 else tmp3907)
tmp3851 = (tmp3852 if s2 else tmp3900)
tmp3829 = (tmp3830 if s3 else tmp3851)
tmp3926 = (tmp3434 if depth5 else tmp3886)
tmp3925 = (tmp3926 if depth4 else tmp3874)
tmp3924 = (tmp3925 if depth3 else tmp3874)
tmp3923 = (tmp3924 if depth2 else tmp3910)
tmp3922 = (tmp3923 if depth1 else tmp3914)
tmp3930 = (tmp3434 if depth4 else tmp3874)
tmp3929 = (tmp3930 if depth3 else tmp3874)
tmp3928 = (tmp3929 if depth2 else tmp3915)
tmp3927 = (tmp3928 if depth1 else tmp3923)
tmp3921 = (tmp3922 if s0 else tmp3927)
tmp3934 = (tmp3930 if depth3 else tmp3911)
tmp3933 = (tmp3934 if depth2 else tmp3924)
tmp3932 = (tmp3933 if depth1 else tmp3928)
tmp3937 = (tmp3930 if depth3 else tmp3916)
tmp3936 = (tmp3937 if depth2 else tmp3929)
tmp3935 = (tmp3936 if depth1 else tmp3933)
tmp3931 = (tmp3932 if s0 else tmp3935)
tmp3920 = (tmp3921 if s1 else tmp3931)
tmp3942 = (tmp3930 if depth3 else tmp3925)
tmp3941 = (tmp3942 if depth2 else tmp3934)
tmp3940 = (tmp3941 if depth1 else tmp3936)
tmp3944 = (tmp3930 if depth2 else tmp3937)
tmp3943 = (tmp3944 if depth1 else tmp3941)
tmp3939 = (tmp3940 if s0 else tmp3943)
tmp3949 = (tmp3434 if depth4 else tmp3912)
tmp3948 = (tmp3949 if depth3 else tmp3930)
tmp3947 = (tmp3948 if depth2 else tmp3942)
tmp3946 = (tmp3947 if depth1 else tmp3944)
tmp3953 = (tmp3434 if depth4 else tmp3917)
tmp3952 = (tmp3953 if depth3 else tmp3930)
tmp3951 = (tmp3952 if depth2 else tmp3930)
tmp3950 = (tmp3951 if depth1 else tmp3947)
tmp3945 = (tmp3946 if s0 else tmp3950)
tmp3938 = (tmp3939 if s1 else tmp3945)
tmp3919 = (tmp3920 if s2 else tmp3938)
tmp3960 = (tmp3434 if depth4 else tmp3926)
tmp3959 = (tmp3960 if depth3 else tmp3930)
tmp3958 = (tmp3959 if depth2 else tmp3948)
tmp3957 = (tmp3958 if depth1 else tmp3951)
tmp3963 = (tmp3434 if depth3 else tmp3930)
tmp3962 = (tmp3963 if depth2 else tmp3952)
tmp3961 = (tmp3962 if depth1 else tmp3958)
tmp3956 = (tmp3957 if s0 else tmp3961)
tmp3967 = (tmp3434 if depth3 else tmp3949)
tmp3966 = (tmp3967 if depth2 else tmp3959)
tmp3965 = (tmp3966 if depth1 else tmp3962)
tmp3970 = (tmp3434 if depth3 else tmp3953)
tmp3969 = (tmp3970 if depth2 else tmp3963)
tmp3968 = (tmp3969 if depth1 else tmp3966)
tmp3964 = (tmp3965 if s0 else tmp3968)
tmp3955 = (tmp3956 if s1 else tmp3964)
tmp3975 = (tmp3434 if depth3 else tmp3960)
tmp3974 = (tmp3975 if depth2 else tmp3967)
tmp3973 = (tmp3974 if depth1 else tmp3969)
tmp3977 = (tmp3434 if depth2 else tmp3970)
tmp3976 = (tmp3977 if depth1 else tmp3974)
tmp3972 = (tmp3973 if s0 else tmp3976)
tmp3980 = (tmp3434 if depth2 else tmp3975)
tmp3979 = (tmp3980 if depth1 else tmp3977)
tmp3981 = (tmp3434 if depth1 else tmp3980)
tmp3978 = (tmp3979 if s0 else tmp3981)
tmp3971 = (tmp3972 if s1 else tmp3978)
tmp3954 = (tmp3955 if s2 else tmp3971)
tmp3918 = (tmp3919 if s3 else tmp3954)
tmp3828 = (tmp3829 if s4 else tmp3918)
tmp3635 = (1 - (tmp3636 if s5 else tmp3828))
tmp3281 = (tmp3282 if s6 else tmp3635)
tmp3257 = (tmp3258 if s7 else tmp3281)
s5n = tmp3257
tmp3991 = (1 if oxygen_full else 0)
tmp3990 = (tmp3991 if k2 else 1)
tmp3989 = (tmp3990 if k1 else 1)
tmp3988 = (tmp3989 if s0 else tmp3990)
tmp3987 = (1 if s1 else tmp3988)
tmp3994 = (tmp3991 if k1 else tmp3990)
tmp3993 = (tmp3994 if s0 else tmp3991)
tmp3992 = (tmp3993 if s1 else tmp3991)
tmp3986 = (tmp3987 if s2 else tmp3992)
tmp3985 = (tmp3986 if s3 else tmp3991)
tmp3984 = (1 if s4 else tmp3985)
tmp4001 = (1 if k2 else tmp3991)
tmp4000 = (tmp4001 if k1 else tmp3991)
tmp3999 = (tmp4000 if s0 else tmp4001)
tmp3998 = (tmp3991 if s1 else tmp3999)
tmp4004 = (1 if k1 else tmp4001)
tmp4003 = (tmp4004 if s0 else 1)
tmp4002 = (tmp4003 if s1 else 1)
tmp3997 = (tmp3998 if s2 else tmp4002)
tmp3996 = (tmp3997 if s3 else 1)
tmp3995 = (tmp3996 if s4 else tmp3985)
tmp3983 = (tmp3984 if s6 else tmp3995)
tmp4021 = (1 if action1_1 else 0)
tmp4020 = (1 if action2_1 else tmp4021)
tmp4019 = (1 if action3_1 else tmp4020)
tmp4018 = (tmp4019 if action4_1 else 0)
tmp4023 = (1 - (tmp4019 if action4_1 else 0))
tmp4022 = (1 - (1 if oxygen_low else tmp4023))
tmp4017 = (tmp4018 if oxygen_full else tmp4022)
tmp4029 = (1 - (1 if action1_1 else 0))
tmp4028 = (tmp4021 if action2_1 else tmp4029)
tmp4030 = (1 if action2_1 else tmp4029)
tmp4027 = (tmp4028 if action3_1 else tmp4030)
tmp4026 = (1 if action4_1 else tmp4027)
tmp4025 = (tmp4026 if oxygen_low else tmp4018)
tmp4024 = (tmp4018 if oxygen_full else tmp4025)
tmp4016 = (tmp4017 if k2 else tmp4024)
tmp4031 = (tmp4017 if k2 else tmp4018)
tmp4015 = (tmp4016 if depth7 else tmp4031)
tmp4014 = (tmp4015 if depth6 else tmp4031)
tmp4032 = (tmp4014 if depth5 else tmp4031)
tmp4013 = (tmp4014 if depth4 else tmp4032)
tmp4042 = (1 - (tmp4028 if action3_1 else tmp4030))
tmp4041 = (1 - (tmp4019 if action4_1 else tmp4042))
tmp4040 = (1 - (1 if oxygen_low else tmp4041))
tmp4039 = (tmp4018 if oxygen_full else tmp4040)
tmp4045 = (tmp4019 if action4_1 else tmp4042)
tmp4044 = (tmp4018 if oxygen_low else tmp4045)
tmp4043 = (tmp4018 if oxygen_full else tmp4044)
tmp4038 = (tmp4039 if k2 else tmp4043)
tmp4037 = (tmp4031 if diver_found else tmp4038)
tmp4036 = (tmp4031 if depth7 else tmp4037)
tmp4035 = (tmp4031 if depth6 else tmp4036)
tmp4034 = (tmp4014 if depth5 else tmp4035)
tmp4033 = (tmp4014 if depth4 else tmp4034)
tmp4012 = (tmp4013 if depth3 else tmp4033)
tmp4052 = (tmp4016 if k1 else tmp4031)
tmp4051 = (tmp4052 if depth7 else tmp4031)
tmp4050 = (tmp4051 if depth6 else tmp4031)
tmp4049 = (tmp4014 if depth5 else tmp4050)
tmp4048 = (tmp4049 if depth4 else tmp4034)
tmp4047 = (tmp4033 if depth3 else tmp4048)
tmp4046 = (tmp4012 if depth2 else tmp4047)
tmp4011 = (1 - (tmp4012 if depth1 else tmp4046))
tmp4010 = (1 if s1 else tmp4011)
tmp4009 = (1 if s2 else tmp4010)
tmp4060 = (tmp4018 if oxygen_full else 0)
tmp4062 = (tmp4018 if oxygen_full else tmp4026)
tmp4061 = (tmp4060 if k2 else tmp4062)
tmp4059 = (tmp4060 if k1 else tmp4061)
tmp4064 = (tmp4060 if k2 else tmp4018)
tmp4063 = (tmp4060 if k1 else tmp4064)
tmp4058 = (tmp4059 if depth7 else tmp4063)
tmp4057 = (tmp4058 if depth6 else tmp4063)
tmp4065 = (tmp4057 if depth5 else tmp4063)
tmp4056 = (tmp4057 if depth4 else tmp4065)
tmp4055 = (tmp4056 if s0 else tmp4060)
tmp4054 = (tmp4055 if s1 else tmp4060)
tmp4074 = (1 - (1 if action4_1 else tmp4027))
tmp4073 = (tmp4018 if oxygen_full else tmp4074)
tmp4072 = (tmp4073 if k2 else tmp4060)
tmp4071 = (tmp4072 if k1 else tmp4060)
tmp4077 = (tmp4018 if oxygen_full else tmp4023)
tmp4076 = (tmp4077 if k2 else tmp4060)
tmp4075 = (tmp4076 if k1 else tmp4060)
tmp4070 = (tmp4071 if depth7 else tmp4075)
tmp4069 = (tmp4070 if depth6 else tmp4075)
tmp4081 = (tmp4069 if depth5 else tmp4075)
tmp4080 = (tmp4069 if depth4 else tmp4081)
tmp4079 = (tmp4069 if depth3 else tmp4080)
tmp4078 = (tmp4069 if depth2 else tmp4079)
tmp4068 = (tmp4069 if depth1 else tmp4078)
tmp4084 = (tmp4072 if depth7 else tmp4076)
tmp4083 = (tmp4084 if depth6 else tmp4076)
tmp4091 = (tmp4072 if k1 else tmp4076)
tmp4090 = (tmp4091 if depth7 else tmp4076)
tmp4089 = (tmp4090 if depth6 else tmp4076)
tmp4088 = (tmp4083 if depth5 else tmp4089)
tmp4087 = (tmp4083 if depth4 else tmp4088)
tmp4086 = (tmp4083 if depth3 else tmp4087)
tmp4085 = (tmp4083 if depth2 else tmp4086)
tmp4082 = (tmp4083 if depth1 else tmp4085)
tmp4067 = (tmp4068 if s0 else tmp4082)
tmp4100 = (tmp4073 if k1 else tmp4072)
tmp4101 = (tmp4077 if k1 else tmp4076)
tmp4099 = (tmp4100 if depth7 else tmp4101)
tmp4104 = (tmp4073 if k2 else tmp4077)
tmp4103 = (tmp4104 if k1 else tmp4076)
tmp4102 = (tmp4103 if depth7 else tmp4101)
tmp4098 = (tmp4099 if depth6 else tmp4102)
tmp4105 = (tmp4099 if depth6 else tmp4101)
tmp4097 = (tmp4098 if depth5 else tmp4105)
tmp4096 = (tmp4097 if depth4 else tmp4105)
tmp4095 = (tmp4096 if depth3 else tmp4105)
tmp4094 = (tmp4095 if depth2 else tmp4105)
tmp4112 = (tmp4104 if k1 else tmp4072)
tmp4111 = (tmp4112 if depth7 else tmp4101)
tmp4110 = (tmp4111 if depth6 else tmp4101)
tmp4109 = (tmp4105 if depth5 else tmp4110)
tmp4108 = (tmp4105 if depth4 else tmp4109)
tmp4107 = (tmp4105 if depth3 else tmp4108)
tmp4106 = (tmp4105 if depth2 else tmp4107)
tmp4093 = (tmp4094 if depth1 else tmp4106)
tmp4119 = (tmp4073 if depth7 else tmp4077)
tmp4120 = (tmp4104 if depth7 else tmp4077)
tmp4118 = (tmp4119 if depth6 else tmp4120)
tmp4121 = (tmp4119 if depth6 else tmp4077)
tmp4117 = (tmp4118 if depth5 else tmp4121)
tmp4116 = (tmp4117 if depth4 else tmp4121)
tmp4115 = (tmp4116 if depth3 else tmp4121)
tmp4114 = (tmp4115 if depth2 else tmp4121)
tmp4128 = (tmp4104 if k1 else tmp4077)
tmp4127 = (tmp4128 if depth7 else tmp4077)
tmp4126 = (tmp4119 if depth6 else tmp4127)
tmp4125 = (tmp4126 if depth5 else tmp4121)
tmp4124 = (tmp4125 if depth4 else tmp4121)
tmp4123 = (tmp4124 if depth3 else tmp4121)
tmp4134 = (tmp4073 if k1 else tmp4104)
tmp4133 = (tmp4134 if depth7 else tmp4077)
tmp4132 = (tmp4133 if depth6 else tmp4077)
tmp4131 = (tmp4121 if depth5 else tmp4132)
tmp4130 = (tmp4121 if depth4 else tmp4131)
tmp4129 = (tmp4121 if depth3 else tmp4130)
tmp4122 = (tmp4123 if depth2 else tmp4129)
tmp4113 = (tmp4114 if depth1 else tmp4122)
tmp4092 = (tmp4093 if s0 else tmp4113)
tmp4066 = (tmp4067 if s1 else tmp4092)
tmp4053 = (1 - (tmp4054 if s2 else tmp4066))
tmp4008 = (tmp4009 if s3 else tmp4053)
tmp4007 = (tmp3996 if s4 else tmp4008)
tmp4145 = (tmp4119 if depth6 else tmp4133)
tmp4144 = (tmp4145 if depth5 else tmp4121)
tmp4143 = (tmp4144 if depth4 else tmp4121)
tmp4142 = (tmp4143 if depth3 else tmp4121)
tmp4141 = (tmp4142 if depth2 else tmp4123)
tmp4140 = (tmp4141 if depth1 else tmp4114)
tmp4150 = (tmp4119 if depth5 else tmp4121)
tmp4149 = (tmp4150 if depth4 else tmp4121)
tmp4148 = (tmp4149 if depth3 else tmp4121)
tmp4147 = (tmp4148 if depth2 else tmp4115)
tmp4146 = (tmp4147 if depth1 else tmp4141)
tmp4139 = (tmp4140 if s0 else tmp4146)
tmp4154 = (tmp4149 if depth3 else tmp4124)
tmp4153 = (tmp4154 if depth2 else tmp4142)
tmp4152 = (tmp4153 if depth1 else tmp4147)
tmp4157 = (tmp4149 if depth3 else tmp4116)
tmp4156 = (tmp4157 if depth2 else tmp4148)
tmp4155 = (tmp4156 if depth1 else tmp4153)
tmp4151 = (tmp4152 if s0 else tmp4155)
tmp4138 = (tmp4139 if s1 else tmp4151)
tmp4162 = (tmp4149 if depth3 else tmp4143)
tmp4161 = (tmp4162 if depth2 else tmp4154)
tmp4160 = (tmp4161 if depth1 else tmp4156)
tmp4164 = (tmp4149 if depth2 else tmp4157)
tmp4163 = (tmp4164 if depth1 else tmp4161)
tmp4159 = (tmp4160 if s0 else tmp4163)
tmp4173 = (tmp4018 if oxygen_full else 1)
tmp4172 = (tmp4173 if k2 else tmp4073)
tmp4171 = (tmp4172 if k1 else tmp4073)
tmp4175 = (tmp4173 if k2 else tmp4077)
tmp4174 = (tmp4175 if k1 else tmp4077)
tmp4170 = (tmp4171 if depth7 else tmp4174)
tmp4176 = (tmp4170 if depth6 else tmp4174)
tmp4169 = (tmp4170 if depth5 else tmp4176)
tmp4168 = (tmp4169 if depth4 else tmp4176)
tmp4182 = (tmp4172 if k1 else tmp4104)
tmp4181 = (tmp4182 if depth7 else tmp4174)
tmp4180 = (tmp4170 if depth6 else tmp4181)
tmp4179 = (tmp4180 if depth5 else tmp4176)
tmp4178 = (tmp4179 if depth4 else tmp4176)
tmp4177 = (tmp4168 if depth3 else tmp4178)
tmp4167 = (tmp4168 if depth2 else tmp4177)
tmp4189 = (tmp4175 if k1 else tmp4104)
tmp4188 = (tmp4189 if depth7 else tmp4174)
tmp4187 = (tmp4170 if depth6 else tmp4188)
tmp4186 = (tmp4187 if depth5 else tmp4176)
tmp4185 = (tmp4186 if depth4 else tmp4176)
tmp4184 = (tmp4168 if depth3 else tmp4185)
tmp4183 = (tmp4168 if depth2 else tmp4184)
tmp4166 = (tmp4167 if depth1 else tmp4183)
tmp4193 = (tmp4172 if depth7 else tmp4175)
tmp4194 = (tmp4193 if depth6 else tmp4175)
tmp4192 = (tmp4193 if depth5 else tmp4194)
tmp4191 = (tmp4192 if depth4 else tmp4194)
tmp4201 = (tmp4172 if k1 else tmp4175)
tmp4200 = (tmp4201 if depth7 else tmp4175)
tmp4199 = (tmp4193 if depth6 else tmp4200)
tmp4198 = (tmp4199 if depth5 else tmp4194)
tmp4197 = (tmp4198 if depth4 else tmp4194)
tmp4196 = (tmp4191 if depth3 else tmp4197)
tmp4195 = (tmp4191 if depth2 else tmp4196)
tmp4190 = (tmp4191 if depth1 else tmp4195)
tmp4165 = (tmp4166 if s0 else tmp4190)
tmp4158 = (tmp4159 if s1 else tmp4165)
tmp4137 = (tmp4138 if s2 else tmp4158)
tmp4208 = (tmp4173 if k1 else tmp4172)
tmp4209 = (tmp4173 if k1 else tmp4175)
tmp4207 = (tmp4208 if depth7 else tmp4209)
tmp4210 = (tmp4207 if depth6 else tmp4209)
tmp4206 = (tmp4207 if depth5 else tmp4210)
tmp4205 = (tmp4206 if depth4 else tmp4210)
tmp4204 = (tmp4205 if s0 else tmp4173)
tmp4203 = (tmp4204 if s1 else tmp4173)
tmp4217 = (tmp4062 if k2 else tmp4173)
tmp4216 = (tmp4217 if k1 else tmp4173)
tmp4219 = (tmp4018 if k2 else tmp4173)
tmp4218 = (tmp4219 if k1 else tmp4173)
tmp4215 = (tmp4216 if depth7 else tmp4218)
tmp4220 = (tmp4215 if depth6 else tmp4218)
tmp4214 = (tmp4215 if depth5 else tmp4220)
tmp4223 = (tmp4214 if depth4 else tmp4220)
tmp4222 = (tmp4214 if depth3 else tmp4223)
tmp4221 = (tmp4214 if depth2 else tmp4222)
tmp4213 = (tmp4214 if depth1 else tmp4221)
tmp4226 = (tmp4217 if depth7 else tmp4219)
tmp4227 = (tmp4226 if depth6 else tmp4219)
tmp4225 = (tmp4226 if depth5 else tmp4227)
tmp4234 = (tmp4217 if k1 else tmp4219)
tmp4233 = (tmp4234 if depth7 else tmp4219)
tmp4232 = (tmp4226 if depth6 else tmp4233)
tmp4231 = (tmp4232 if depth5 else tmp4227)
tmp4230 = (tmp4225 if depth4 else tmp4231)
tmp4229 = (tmp4225 if depth3 else tmp4230)
tmp4228 = (tmp4225 if depth2 else tmp4229)
tmp4224 = (tmp4225 if depth1 else tmp4228)
tmp4212 = (tmp4213 if s0 else tmp4224)
tmp4242 = (tmp4062 if k1 else tmp4217)
tmp4243 = (tmp4018 if k1 else tmp4219)
tmp4241 = (tmp4242 if depth7 else tmp4243)
tmp4247 = (tmp4062 if k2 else tmp4018)
tmp4246 = (tmp4247 if k1 else tmp4219)
tmp4245 = (tmp4246 if depth7 else tmp4243)
tmp4244 = (tmp4241 if depth6 else tmp4245)
tmp4240 = (tmp4241 if depth5 else tmp4244)
tmp4249 = (tmp4241 if depth6 else tmp4243)
tmp4248 = (tmp4241 if depth5 else tmp4249)
tmp4239 = (tmp4240 if depth4 else tmp4248)
tmp4238 = (tmp4239 if depth3 else tmp4248)
tmp4237 = (tmp4238 if depth2 else tmp4248)
tmp4256 = (tmp4247 if k1 else tmp4217)
tmp4255 = (tmp4256 if depth7 else tmp4243)
tmp4254 = (tmp4241 if depth6 else tmp4255)
tmp4253 = (tmp4254 if depth5 else tmp4249)
tmp4252 = (tmp4248 if depth4 else tmp4253)
tmp4251 = (tmp4248 if depth3 else tmp4252)
tmp4250 = (tmp4248 if depth2 else tmp4251)
tmp4236 = (tmp4237 if depth1 else tmp4250)
tmp4262 = (tmp4062 if depth7 else tmp4018)
tmp4264 = (tmp4247 if depth7 else tmp4018)
tmp4263 = (tmp4262 if depth6 else tmp4264)
tmp4261 = (tmp4262 if depth5 else tmp4263)
tmp4266 = (tmp4262 if depth6 else tmp4018)
tmp4265 = (tmp4262 if depth5 else tmp4266)
tmp4260 = (tmp4261 if depth4 else tmp4265)
tmp4259 = (tmp4260 if depth3 else tmp4265)
tmp4258 = (tmp4259 if depth2 else tmp4265)
tmp4273 = (tmp4247 if k1 else tmp4018)
tmp4272 = (tmp4273 if depth7 else tmp4018)
tmp4271 = (tmp4262 if depth6 else tmp4272)
tmp4270 = (tmp4262 if depth5 else tmp4271)
tmp4269 = (tmp4270 if depth4 else tmp4265)
tmp4268 = (tmp4269 if depth3 else tmp4265)
tmp4279 = (tmp4062 if k1 else tmp4247)
tmp4278 = (tmp4279 if depth7 else tmp4018)
tmp4277 = (tmp4262 if depth6 else tmp4278)
tmp4276 = (tmp4277 if depth5 else tmp4266)
tmp4275 = (tmp4265 if depth4 else tmp4276)
tmp4274 = (tmp4265 if depth3 else tmp4275)
tmp4267 = (tmp4268 if depth2 else tmp4274)
tmp4257 = (tmp4258 if depth1 else tmp4267)
tmp4235 = (tmp4236 if s0 else tmp4257)
tmp4211 = (tmp4212 if s1 else tmp4235)
tmp4202 = (tmp4203 if s2 else tmp4211)
tmp4136 = (tmp4137 if s3 else tmp4202)
tmp4288 = (tmp4262 if depth5 else tmp4277)
tmp4287 = (tmp4288 if depth4 else tmp4265)
tmp4286 = (tmp4287 if depth3 else tmp4265)
tmp4285 = (tmp4286 if depth2 else tmp4268)
tmp4284 = (tmp4285 if depth1 else tmp4258)
tmp4292 = (tmp4262 if depth4 else tmp4265)
tmp4291 = (tmp4292 if depth3 else tmp4265)
tmp4290 = (tmp4291 if depth2 else tmp4259)
tmp4289 = (tmp4290 if depth1 else tmp4285)
tmp4283 = (tmp4284 if s0 else tmp4289)
tmp4296 = (tmp4292 if depth3 else tmp4269)
tmp4295 = (tmp4296 if depth2 else tmp4286)
tmp4294 = (tmp4295 if depth1 else tmp4290)
tmp4299 = (tmp4292 if depth3 else tmp4260)
tmp4298 = (tmp4299 if depth2 else tmp4291)
tmp4297 = (tmp4298 if depth1 else tmp4295)
tmp4293 = (tmp4294 if s0 else tmp4297)
tmp4282 = (tmp4283 if s1 else tmp4293)
tmp4304 = (tmp4292 if depth3 else tmp4287)
tmp4303 = (tmp4304 if depth2 else tmp4296)
tmp4302 = (tmp4303 if depth1 else tmp4298)
tmp4306 = (tmp4292 if depth2 else tmp4299)
tmp4305 = (tmp4306 if depth1 else tmp4303)
tmp4301 = (tmp4302 if s0 else tmp4305)
tmp4312 = (tmp4061 if k1 else tmp4062)
tmp4313 = (tmp4064 if k1 else tmp4018)
tmp4311 = (tmp4312 if depth7 else tmp4313)
tmp4315 = (tmp4311 if depth6 else tmp4313)
tmp4314 = (tmp4311 if depth5 else tmp4315)
tmp4310 = (tmp4311 if depth4 else tmp4314)
tmp4321 = (tmp4061 if k1 else tmp4247)
tmp4320 = (tmp4321 if depth7 else tmp4313)
tmp4319 = (tmp4311 if depth6 else tmp4320)
tmp4318 = (tmp4311 if depth5 else tmp4319)
tmp4317 = (tmp4318 if depth4 else tmp4314)
tmp4316 = (tmp4310 if depth3 else tmp4317)
tmp4309 = (tmp4310 if depth2 else tmp4316)
tmp4328 = (tmp4064 if k1 else tmp4247)
tmp4327 = (tmp4328 if depth7 else tmp4313)
tmp4326 = (tmp4311 if depth6 else tmp4327)
tmp4325 = (tmp4311 if depth5 else tmp4326)
tmp4324 = (tmp4325 if depth4 else tmp4314)
tmp4323 = (tmp4310 if depth3 else tmp4324)
tmp4322 = (tmp4310 if depth2 else tmp4323)
tmp4308 = (tmp4309 if depth1 else tmp4322)
tmp4331 = (tmp4061 if depth7 else tmp4064)
tmp4333 = (tmp4331 if depth6 else tmp4064)
tmp4332 = (tmp4331 if depth5 else tmp4333)
tmp4330 = (tmp4331 if depth4 else tmp4332)
tmp4340 = (tmp4061 if k1 else tmp4064)
tmp4339 = (tmp4340 if depth7 else tmp4064)
tmp4338 = (tmp4331 if depth6 else tmp4339)
tmp4337 = (tmp4331 if depth5 else tmp4338)
tmp4336 = (tmp4337 if depth4 else tmp4332)
tmp4335 = (tmp4330 if depth3 else tmp4336)
tmp4334 = (tmp4330 if depth2 else tmp4335)
tmp4329 = (tmp4330 if depth1 else tmp4334)
tmp4307 = (tmp4308 if s0 else tmp4329)
tmp4300 = (tmp4301 if s1 else tmp4307)
tmp4281 = (tmp4282 if s2 else tmp4300)
tmp4345 = (tmp4058 if depth5 else tmp4057)
tmp4344 = (tmp4058 if depth4 else tmp4345)
tmp4343 = (tmp4344 if s0 else tmp4060)
tmp4342 = (tmp4343 if s1 else tmp4060)
tmp4352 = (tmp4070 if depth5 else tmp4069)
tmp4351 = (tmp4070 if depth4 else tmp4352)
tmp4350 = (tmp4070 if depth3 else tmp4351)
tmp4349 = (tmp4070 if depth2 else tmp4350)
tmp4348 = (tmp4070 if depth1 else tmp4349)
tmp4358 = (tmp4084 if depth6 else tmp4090)
tmp4357 = (tmp4084 if depth5 else tmp4358)
tmp4356 = (tmp4084 if depth4 else tmp4357)
tmp4355 = (tmp4084 if depth3 else tmp4356)
tmp4354 = (tmp4084 if depth2 else tmp4355)
tmp4353 = (tmp4084 if depth1 else tmp4354)
tmp4347 = (tmp4348 if s0 else tmp4353)
tmp4366 = (tmp4100 if depth7 else tmp4103)
tmp4365 = (tmp4366 if depth6 else tmp4099)
tmp4364 = (tmp4365 if depth5 else tmp4099)
tmp4363 = (tmp4364 if depth4 else tmp4099)
tmp4362 = (tmp4363 if depth3 else tmp4099)
tmp4361 = (tmp4362 if depth2 else tmp4099)
tmp4371 = (tmp4099 if depth6 else tmp4111)
tmp4370 = (tmp4099 if depth5 else tmp4371)
tmp4369 = (tmp4099 if depth4 else tmp4370)
tmp4368 = (tmp4099 if depth3 else tmp4369)
tmp4367 = (tmp4099 if depth2 else tmp4368)
tmp4360 = (tmp4361 if depth1 else tmp4367)
tmp4378 = (tmp4073 if depth7 else tmp4104)
tmp4377 = (tmp4378 if depth6 else tmp4119)
tmp4376 = (tmp4377 if depth5 else tmp4119)
tmp4375 = (tmp4376 if depth4 else tmp4119)
tmp4374 = (tmp4375 if depth3 else tmp4119)
tmp4373 = (tmp4374 if depth2 else tmp4119)
tmp4384 = (tmp4073 if depth7 else tmp4128)
tmp4383 = (tmp4384 if depth6 else tmp4119)
tmp4382 = (tmp4383 if depth5 else tmp4119)
tmp4381 = (tmp4382 if depth4 else tmp4119)
tmp4380 = (tmp4381 if depth3 else tmp4119)
tmp4387 = (tmp4119 if depth5 else tmp4145)
tmp4386 = (tmp4119 if depth4 else tmp4387)
tmp4385 = (tmp4119 if depth3 else tmp4386)
tmp4379 = (tmp4380 if depth2 else tmp4385)
tmp4372 = (tmp4373 if depth1 else tmp4379)
tmp4359 = (tmp4360 if s0 else tmp4372)
tmp4346 = (tmp4347 if s1 else tmp4359)
tmp4341 = (tmp4342 if s2 else tmp4346)
tmp4280 = (tmp4281 if s3 else tmp4341)
tmp4135 = (1 - (tmp4136 if s4 else tmp4280))
tmp4006 = (tmp4007 if s5 else tmp4135)
tmp4400 = (tmp4073 if depth7 else tmp4134)
tmp4399 = (tmp4400 if depth6 else tmp4119)
tmp4398 = (tmp4399 if depth5 else tmp4119)
tmp4397 = (tmp4398 if depth4 else tmp4119)
tmp4396 = (tmp4397 if depth3 else tmp4119)
tmp4395 = (tmp4396 if depth2 else tmp4380)
tmp4394 = (tmp4395 if depth1 else tmp4373)
tmp4406 = (tmp4073 if depth6 else tmp4119)
tmp4405 = (tmp4406 if depth5 else tmp4119)
tmp4404 = (tmp4405 if depth4 else tmp4119)
tmp4403 = (tmp4404 if depth3 else tmp4119)
tmp4402 = (tmp4403 if depth2 else tmp4374)
tmp4401 = (tmp4402 if depth1 else tmp4395)
tmp4393 = (tmp4394 if s0 else tmp4401)
tmp4410 = (tmp4404 if depth3 else tmp4381)
tmp4409 = (tmp4410 if depth2 else tmp4396)
tmp4408 = (tmp4409 if depth1 else tmp4402)
tmp4413 = (tmp4404 if depth3 else tmp4375)
tmp4412 = (tmp4413 if depth2 else tmp4403)
tmp4411 = (tmp4412 if depth1 else tmp4409)
tmp4407 = (tmp4408 if s0 else tmp4411)
tmp4392 = (tmp4393 if s1 else tmp4407)
tmp4418 = (tmp4404 if depth3 else tmp4397)
tmp4417 = (tmp4418 if depth2 else tmp4410)
tmp4416 = (tmp4417 if depth1 else tmp4412)
tmp4420 = (tmp4404 if depth2 else tmp4413)
tmp4419 = (tmp4420 if depth1 else tmp4417)
tmp4415 = (tmp4416 if s0 else tmp4419)
tmp4426 = (tmp4171 if depth6 else tmp4170)
tmp4425 = (tmp4426 if depth5 else tmp4170)
tmp4424 = (tmp4425 if depth4 else tmp4170)
tmp4431 = (tmp4171 if depth7 else tmp4182)
tmp4430 = (tmp4431 if depth6 else tmp4170)
tmp4429 = (tmp4430 if depth5 else tmp4170)
tmp4428 = (tmp4429 if depth4 else tmp4170)
tmp4427 = (tmp4424 if depth3 else tmp4428)
tmp4423 = (tmp4424 if depth2 else tmp4427)
tmp4437 = (tmp4171 if depth7 else tmp4189)
tmp4436 = (tmp4437 if depth6 else tmp4170)
tmp4435 = (tmp4436 if depth5 else tmp4170)
tmp4434 = (tmp4435 if depth4 else tmp4170)
tmp4433 = (tmp4424 if depth3 else tmp4434)
tmp4432 = (tmp4424 if depth2 else tmp4433)
tmp4422 = (tmp4423 if depth1 else tmp4432)
tmp4441 = (tmp4172 if depth6 else tmp4193)
tmp4440 = (tmp4441 if depth5 else tmp4193)
tmp4439 = (tmp4440 if depth4 else tmp4193)
tmp4447 = (tmp4172 if depth7 else tmp4201)
tmp4446 = (tmp4447 if depth6 else tmp4193)
tmp4445 = (tmp4446 if depth5 else tmp4193)
tmp4444 = (tmp4445 if depth4 else tmp4193)
tmp4443 = (tmp4439 if depth3 else tmp4444)
tmp4442 = (tmp4439 if depth2 else tmp4443)
tmp4438 = (tmp4439 if depth1 else tmp4442)
tmp4421 = (tmp4422 if s0 else tmp4438)
tmp4414 = (tmp4415 if s1 else tmp4421)
tmp4391 = (tmp4392 if s2 else tmp4414)
tmp4453 = (tmp4208 if depth6 else tmp4207)
tmp4452 = (tmp4453 if depth5 else tmp4207)
tmp4451 = (tmp4452 if depth4 else tmp4207)
tmp4450 = (tmp4451 if s0 else tmp4173)
tmp4449 = (tmp4450 if s1 else tmp4173)
tmp4458 = (tmp4216 if depth6 else tmp4215)
tmp4457 = (tmp4458 if depth5 else tmp4215)
tmp4461 = (tmp4457 if depth4 else tmp4215)
tmp4460 = (tmp4457 if depth3 else tmp4461)
tmp4459 = (tmp4457 if depth2 else tmp4460)
tmp4456 = (tmp4457 if depth1 else tmp4459)
tmp4464 = (tmp4217 if depth6 else tmp4226)
tmp4463 = (tmp4464 if depth5 else tmp4226)
tmp4470 = (tmp4217 if depth7 else tmp4234)
tmp4469 = (tmp4470 if depth6 else tmp4226)
tmp4468 = (tmp4469 if depth5 else tmp4226)
tmp4467 = (tmp4463 if depth4 else tmp4468)
tmp4466 = (tmp4463 if depth3 else tmp4467)
tmp4465 = (tmp4463 if depth2 else tmp4466)
tmp4462 = (tmp4463 if depth1 else tmp4465)
tmp4455 = (tmp4456 if s0 else tmp4462)
tmp4477 = (tmp4242 if depth6 else tmp4241)
tmp4479 = (tmp4242 if depth7 else tmp4246)
tmp4478 = (tmp4479 if depth6 else tmp4241)
tmp4476 = (tmp4477 if depth5 else tmp4478)
tmp4480 = (tmp4477 if depth5 else tmp4241)
tmp4475 = (tmp4476 if depth4 else tmp4480)
tmp4474 = (tmp4475 if depth3 else tmp4480)
tmp4473 = (tmp4474 if depth2 else tmp4480)
tmp4486 = (tmp4242 if depth7 else tmp4256)
tmp4485 = (tmp4486 if depth6 else tmp4241)
tmp4484 = (tmp4485 if depth5 else tmp4241)
tmp4483 = (tmp4480 if depth4 else tmp4484)
tmp4482 = (tmp4480 if depth3 else tmp4483)
tmp4481 = (tmp4480 if depth2 else tmp4482)
tmp4472 = (tmp4473 if depth1 else tmp4481)
tmp4492 = (tmp4062 if depth6 else tmp4262)
tmp4494 = (tmp4062 if depth7 else tmp4247)
tmp4493 = (tmp4494 if depth6 else tmp4262)
tmp4491 = (tmp4492 if depth5 else tmp4493)
tmp4495 = (tmp4492 if depth5 else tmp4262)
tmp4490 = (tmp4491 if depth4 else tmp4495)
tmp4489 = (tmp4490 if depth3 else tmp4495)
tmp4488 = (tmp4489 if depth2 else tmp4495)
tmp4501 = (tmp4062 if depth7 else tmp4273)
tmp4500 = (tmp4501 if depth6 else tmp4262)
tmp4499 = (tmp4492 if depth5 else tmp4500)
tmp4498 = (tmp4499 if depth4 else tmp4495)
tmp4497 = (tmp4498 if depth3 else tmp4495)
tmp4506 = (tmp4062 if depth7 else tmp4279)
tmp4505 = (tmp4506 if depth6 else tmp4262)
tmp4504 = (tmp4505 if depth5 else tmp4262)
tmp4503 = (tmp4495 if depth4 else tmp4504)
tmp4502 = (tmp4495 if depth3 else tmp4503)
tmp4496 = (tmp4497 if depth2 else tmp4502)
tmp4487 = (tmp4488 if depth1 else tmp4496)
tmp4471 = (tmp4472 if s0 else tmp4487)
tmp4454 = (tmp4455 if s1 else tmp4471)
tmp4448 = (tmp4449 if s2 else tmp4454)
tmp4390 = (tmp4391 if s3 else tmp4448)
tmp4515 = (tmp4492 if depth5 else tmp4505)
tmp4514 = (tmp4515 if depth4 else tmp4495)
tmp4513 = (tmp4514 if depth3 else tmp4495)
tmp4512 = (tmp4513 if depth2 else tmp4497)
tmp4511 = (tmp4512 if depth1 else tmp4488)
tmp4519 = (tmp4492 if depth4 else tmp4495)
tmp4518 = (tmp4519 if depth3 else tmp4495)
tmp4517 = (tmp4518 if depth2 else tmp4489)
tmp4516 = (tmp4517 if depth1 else tmp4512)
tmp4510 = (tmp4511 if s0 else tmp4516)
tmp4523 = (tmp4519 if depth3 else tmp4498)
tmp4522 = (tmp4523 if depth2 else tmp4513)
tmp4521 = (tmp4522 if depth1 else tmp4517)
tmp4526 = (tmp4519 if depth3 else tmp4490)
tmp4525 = (tmp4526 if depth2 else tmp4518)
tmp4524 = (tmp4525 if depth1 else tmp4522)
tmp4520 = (tmp4521 if s0 else tmp4524)
tmp4509 = (tmp4510 if s1 else tmp4520)
tmp4531 = (tmp4519 if depth3 else tmp4514)
tmp4530 = (tmp4531 if depth2 else tmp4523)
tmp4529 = (tmp4530 if depth1 else tmp4525)
tmp4533 = (tmp4519 if depth2 else tmp4526)
tmp4532 = (tmp4533 if depth1 else tmp4530)
tmp4528 = (tmp4529 if s0 else tmp4532)
tmp4538 = (tmp4312 if depth6 else tmp4311)
tmp4539 = (tmp4538 if depth5 else tmp4311)
tmp4537 = (tmp4538 if depth4 else tmp4539)
tmp4544 = (tmp4312 if depth7 else tmp4321)
tmp4543 = (tmp4544 if depth6 else tmp4311)
tmp4542 = (tmp4538 if depth5 else tmp4543)
tmp4541 = (tmp4542 if depth4 else tmp4539)
tmp4540 = (tmp4537 if depth3 else tmp4541)
tmp4536 = (tmp4537 if depth2 else tmp4540)
tmp4550 = (tmp4312 if depth7 else tmp4328)
tmp4549 = (tmp4550 if depth6 else tmp4311)
tmp4548 = (tmp4538 if depth5 else tmp4549)
tmp4547 = (tmp4548 if depth4 else tmp4539)
tmp4546 = (tmp4537 if depth3 else tmp4547)
tmp4545 = (tmp4537 if depth2 else tmp4546)
tmp4535 = (tmp4536 if depth1 else tmp4545)
tmp4553 = (tmp4061 if depth6 else tmp4331)
tmp4554 = (tmp4553 if depth5 else tmp4331)
tmp4552 = (tmp4553 if depth4 else tmp4554)
tmp4560 = (tmp4061 if depth7 else tmp4340)
tmp4559 = (tmp4560 if depth6 else tmp4331)
tmp4558 = (tmp4553 if depth5 else tmp4559)
tmp4557 = (tmp4558 if depth4 else tmp4554)
tmp4556 = (tmp4552 if depth3 else tmp4557)
tmp4555 = (tmp4552 if depth2 else tmp4556)
tmp4551 = (tmp4552 if depth1 else tmp4555)
tmp4534 = (tmp4535 if s0 else tmp4551)
tmp4527 = (tmp4528 if s1 else tmp4534)
tmp4508 = (tmp4509 if s2 else tmp4527)
tmp4565 = (tmp4059 if depth6 else tmp4058)
tmp4566 = (tmp4565 if depth5 else tmp4058)
tmp4564 = (tmp4565 if depth4 else tmp4566)
tmp4563 = (tmp4564 if s0 else tmp4060)
tmp4562 = (tmp4563 if s1 else tmp4060)
tmp4570 = (tmp4071 if depth6 else tmp4070)
tmp4574 = (tmp4570 if depth5 else tmp4070)
tmp4573 = (tmp4570 if depth4 else tmp4574)
tmp4572 = (tmp4570 if depth3 else tmp4573)
tmp4571 = (tmp4570 if depth2 else tmp4572)
tmp4569 = (tmp4570 if depth1 else tmp4571)
tmp4576 = (tmp4072 if depth6 else tmp4084)
tmp4582 = (tmp4072 if depth7 else tmp4091)
tmp4581 = (tmp4582 if depth6 else tmp4084)
tmp4580 = (tmp4576 if depth5 else tmp4581)
tmp4579 = (tmp4576 if depth4 else tmp4580)
tmp4578 = (tmp4576 if depth3 else tmp4579)
tmp4577 = (tmp4576 if depth2 else tmp4578)
tmp4575 = (tmp4576 if depth1 else tmp4577)
tmp4568 = (tmp4569 if s0 else tmp4575)
tmp4589 = (tmp4100 if depth6 else tmp4366)
tmp4590 = (tmp4100 if depth6 else tmp4099)
tmp4588 = (tmp4589 if depth5 else tmp4590)
tmp4587 = (tmp4588 if depth4 else tmp4590)
tmp4586 = (tmp4587 if depth3 else tmp4590)
tmp4585 = (tmp4586 if depth2 else tmp4590)
tmp4596 = (tmp4100 if depth7 else tmp4112)
tmp4595 = (tmp4596 if depth6 else tmp4099)
tmp4594 = (tmp4590 if depth5 else tmp4595)
tmp4593 = (tmp4590 if depth4 else tmp4594)
tmp4592 = (tmp4590 if depth3 else tmp4593)
tmp4591 = (tmp4590 if depth2 else tmp4592)
tmp4584 = (tmp4585 if depth1 else tmp4591)
tmp4602 = (tmp4073 if depth6 else tmp4378)
tmp4601 = (tmp4602 if depth5 else tmp4406)
tmp4600 = (tmp4601 if depth4 else tmp4406)
tmp4599 = (tmp4600 if depth3 else tmp4406)
tmp4598 = (tmp4599 if depth2 else tmp4406)
tmp4607 = (tmp4073 if depth6 else tmp4384)
tmp4606 = (tmp4607 if depth5 else tmp4406)
tmp4605 = (tmp4606 if depth4 else tmp4406)
tmp4604 = (tmp4605 if depth3 else tmp4406)
tmp4610 = (tmp4406 if depth5 else tmp4399)
tmp4609 = (tmp4406 if depth4 else tmp4610)
tmp4608 = (tmp4406 if depth3 else tmp4609)
tmp4603 = (tmp4604 if depth2 else tmp4608)
tmp4597 = (tmp4598 if depth1 else tmp4603)
tmp4583 = (tmp4584 if s0 else tmp4597)
tmp4567 = (tmp4568 if s1 else tmp4583)
tmp4561 = (tmp4562 if s2 else tmp4567)
tmp4507 = (tmp4508 if s3 else tmp4561)
tmp4389 = (tmp4390 if s4 else tmp4507)
tmp4621 = (tmp4073 if depth6 else tmp4400)
tmp4620 = (tmp4621 if depth5 else tmp4406)
tmp4619 = (tmp4620 if depth4 else tmp4406)
tmp4618 = (tmp4619 if depth3 else tmp4406)
tmp4617 = (tmp4618 if depth2 else tmp4604)
tmp4616 = (tmp4617 if depth1 else tmp4598)
tmp4626 = (tmp4073 if depth5 else tmp4406)
tmp4625 = (tmp4626 if depth4 else tmp4406)
tmp4624 = (tmp4625 if depth3 else tmp4406)
tmp4623 = (tmp4624 if depth2 else tmp4599)
tmp4622 = (tmp4623 if depth1 else tmp4617)
tmp4615 = (tmp4616 if s0 else tmp4622)
tmp4630 = (tmp4625 if depth3 else tmp4605)
tmp4629 = (tmp4630 if depth2 else tmp4618)
tmp4628 = (tmp4629 if depth1 else tmp4623)
tmp4633 = (tmp4625 if depth3 else tmp4600)
tmp4632 = (tmp4633 if depth2 else tmp4624)
tmp4631 = (tmp4632 if depth1 else tmp4629)
tmp4627 = (tmp4628 if s0 else tmp4631)
tmp4614 = (tmp4615 if s1 else tmp4627)
tmp4638 = (tmp4625 if depth3 else tmp4619)
tmp4637 = (tmp4638 if depth2 else tmp4630)
tmp4636 = (tmp4637 if depth1 else tmp4632)
tmp4640 = (tmp4625 if depth2 else tmp4633)
tmp4639 = (tmp4640 if depth1 else tmp4637)
tmp4635 = (tmp4636 if s0 else tmp4639)
tmp4645 = (tmp4171 if depth5 else tmp4426)
tmp4644 = (tmp4645 if depth4 else tmp4426)
tmp4649 = (tmp4171 if depth6 else tmp4431)
tmp4648 = (tmp4649 if depth5 else tmp4426)
tmp4647 = (tmp4648 if depth4 else tmp4426)
tmp4646 = (tmp4644 if depth3 else tmp4647)
tmp4643 = (tmp4644 if depth2 else tmp4646)
tmp4654 = (tmp4171 if depth6 else tmp4437)
tmp4653 = (tmp4654 if depth5 else tmp4426)
tmp4652 = (tmp4653 if depth4 else tmp4426)
tmp4651 = (tmp4644 if depth3 else tmp4652)
tmp4650 = (tmp4644 if depth2 else tmp4651)
tmp4642 = (tmp4643 if depth1 else tmp4650)
tmp4657 = (tmp4172 if depth5 else tmp4441)
tmp4656 = (tmp4657 if depth4 else tmp4441)
tmp4662 = (tmp4172 if depth6 else tmp4447)
tmp4661 = (tmp4662 if depth5 else tmp4441)
tmp4660 = (tmp4661 if depth4 else tmp4441)
tmp4659 = (tmp4656 if depth3 else tmp4660)
tmp4658 = (tmp4656 if depth2 else tmp4659)
tmp4655 = (tmp4656 if depth1 else tmp4658)
tmp4641 = (tmp4642 if s0 else tmp4655)
tmp4634 = (tmp4635 if s1 else tmp4641)
tmp4613 = (tmp4614 if s2 else tmp4634)
tmp4667 = (tmp4208 if depth5 else tmp4453)
tmp4666 = (tmp4667 if depth4 else tmp4453)
tmp4665 = (tmp4666 if s0 else tmp4173)
tmp4664 = (tmp4665 if s1 else tmp4173)
tmp4671 = (tmp4216 if depth5 else tmp4458)
tmp4674 = (tmp4671 if depth4 else tmp4458)
tmp4673 = (tmp4671 if depth3 else tmp4674)
tmp4672 = (tmp4671 if depth2 else tmp4673)
tmp4670 = (tmp4671 if depth1 else tmp4672)
tmp4676 = (tmp4217 if depth5 else tmp4464)
tmp4681 = (tmp4217 if depth6 else tmp4470)
tmp4680 = (tmp4681 if depth5 else tmp4464)
tmp4679 = (tmp4676 if depth4 else tmp4680)
tmp4678 = (tmp4676 if depth3 else tmp4679)
tmp4677 = (tmp4676 if depth2 else tmp4678)
tmp4675 = (tmp4676 if depth1 else tmp4677)
tmp4669 = (tmp4670 if s0 else tmp4675)
tmp4688 = (tmp4242 if depth6 else tmp4479)
tmp4687 = (tmp4242 if depth5 else tmp4688)
tmp4689 = (tmp4242 if depth5 else tmp4477)
tmp4686 = (tmp4687 if depth4 else tmp4689)
tmp4685 = (tmp4686 if depth3 else tmp4689)
tmp4684 = (tmp4685 if depth2 else tmp4689)
tmp4694 = (tmp4242 if depth6 else tmp4486)
tmp4693 = (tmp4694 if depth5 else tmp4477)
tmp4692 = (tmp4689 if depth4 else tmp4693)
tmp4691 = (tmp4689 if depth3 else tmp4692)
tmp4690 = (tmp4689 if depth2 else tmp4691)
tmp4683 = (tmp4684 if depth1 else tmp4690)
tmp4700 = (tmp4062 if depth6 else tmp4494)
tmp4699 = (tmp4062 if depth5 else tmp4700)
tmp4701 = (tmp4062 if depth5 else tmp4492)
tmp4698 = (tmp4699 if depth4 else tmp4701)
tmp4697 = (tmp4698 if depth3 else tmp4701)
tmp4696 = (tmp4697 if depth2 else tmp4701)
tmp4706 = (tmp4062 if depth6 else tmp4501)
tmp4705 = (tmp4062 if depth5 else tmp4706)
tmp4704 = (tmp4705 if depth4 else tmp4701)
tmp4703 = (tmp4704 if depth3 else tmp4701)
tmp4710 = (tmp4062 if depth6 else tmp4506)
tmp4709 = (tmp4710 if depth5 else tmp4492)
tmp4708 = (tmp4701 if depth4 else tmp4709)
tmp4707 = (tmp4701 if depth3 else tmp4708)
tmp4702 = (tmp4703 if depth2 else tmp4707)
tmp4695 = (tmp4696 if depth1 else tmp4702)
tmp4682 = (tmp4683 if s0 else tmp4695)
tmp4668 = (tmp4669 if s1 else tmp4682)
tmp4663 = (tmp4664 if s2 else tmp4668)
tmp4612 = (tmp4613 if s3 else tmp4663)
tmp4719 = (tmp4062 if depth5 else tmp4710)
tmp4718 = (tmp4719 if depth4 else tmp4701)
tmp4717 = (tmp4718 if depth3 else tmp4701)
tmp4716 = (tmp4717 if depth2 else tmp4703)
tmp4715 = (tmp4716 if depth1 else tmp4696)
tmp4723 = (tmp4062 if depth4 else tmp4701)
tmp4722 = (tmp4723 if depth3 else tmp4701)
tmp4721 = (tmp4722 if depth2 else tmp4697)
tmp4720 = (tmp4721 if depth1 else tmp4716)
tmp4714 = (tmp4715 if s0 else tmp4720)
tmp4727 = (tmp4723 if depth3 else tmp4704)
tmp4726 = (tmp4727 if depth2 else tmp4717)
tmp4725 = (tmp4726 if depth1 else tmp4721)
tmp4730 = (tmp4723 if depth3 else tmp4698)
tmp4729 = (tmp4730 if depth2 else tmp4722)
tmp4728 = (tmp4729 if depth1 else tmp4726)
tmp4724 = (tmp4725 if s0 else tmp4728)
tmp4713 = (tmp4714 if s1 else tmp4724)
tmp4735 = (tmp4723 if depth3 else tmp4718)
tmp4734 = (tmp4735 if depth2 else tmp4727)
tmp4733 = (tmp4734 if depth1 else tmp4729)
tmp4737 = (tmp4723 if depth2 else tmp4730)
tmp4736 = (tmp4737 if depth1 else tmp4734)
tmp4732 = (tmp4733 if s0 else tmp4736)
tmp4742 = (tmp4312 if depth5 else tmp4538)
tmp4741 = (tmp4312 if depth4 else tmp4742)
tmp4746 = (tmp4312 if depth6 else tmp4544)
tmp4745 = (tmp4312 if depth5 else tmp4746)
tmp4744 = (tmp4745 if depth4 else tmp4742)
tmp4743 = (tmp4741 if depth3 else tmp4744)
tmp4740 = (tmp4741 if depth2 else tmp4743)
tmp4751 = (tmp4312 if depth6 else tmp4550)
tmp4750 = (tmp4312 if depth5 else tmp4751)
tmp4749 = (tmp4750 if depth4 else tmp4742)
tmp4748 = (tmp4741 if depth3 else tmp4749)
tmp4747 = (tmp4741 if depth2 else tmp4748)
tmp4739 = (tmp4740 if depth1 else tmp4747)
tmp4754 = (tmp4061 if depth5 else tmp4553)
tmp4753 = (tmp4061 if depth4 else tmp4754)
tmp4759 = (tmp4061 if depth6 else tmp4560)
tmp4758 = (tmp4061 if depth5 else tmp4759)
tmp4757 = (tmp4758 if depth4 else tmp4754)
tmp4756 = (tmp4753 if depth3 else tmp4757)
tmp4755 = (tmp4753 if depth2 else tmp4756)
tmp4752 = (tmp4753 if depth1 else tmp4755)
tmp4738 = (tmp4739 if s0 else tmp4752)
tmp4731 = (tmp4732 if s1 else tmp4738)
tmp4712 = (tmp4713 if s2 else tmp4731)
tmp4764 = (tmp4059 if depth5 else tmp4565)
tmp4763 = (tmp4059 if depth4 else tmp4764)
tmp4762 = (tmp4763 if s0 else tmp4060)
tmp4761 = (tmp4762 if s1 else tmp4060)
tmp4760 = (tmp4761 if s2 else tmp4060)
tmp4711 = (tmp4712 if s3 else tmp4760)
tmp4611 = (tmp4612 if s4 else tmp4711)
tmp4388 = (1 - (tmp4389 if s5 else tmp4611))
tmp4005 = (tmp4006 if s6 else tmp4388)
tmp3982 = (1 - (tmp3983 if s7 else tmp4005))
s4n = tmp3982
tmp4770 = (1 - (1 if oxygen_low else 0))
tmp4769 = (1 if oxygen_full else tmp4770)
tmp4771 = (1 if oxygen_full else 0)
tmp4768 = (tmp4769 if s1 else tmp4771)
tmp4777 = (1 if k2 else tmp4771)
tmp4776 = (tmp4777 if k1 else tmp4771)
tmp4775 = (tmp4776 if s0 else tmp4777)
tmp4774 = (tmp4771 if s1 else tmp4775)
tmp4780 = (1 if k1 else tmp4777)
tmp4779 = (tmp4780 if s0 else 1)
tmp4778 = (tmp4779 if s1 else 1)
tmp4773 = (tmp4774 if s2 else tmp4778)
tmp4785 = (tmp4771 if k2 else 1)
tmp4784 = (tmp4785 if k1 else 1)
tmp4783 = (tmp4784 if s0 else tmp4785)
tmp4782 = (1 if s1 else tmp4783)
tmp4788 = (tmp4771 if k1 else tmp4785)
tmp4787 = (tmp4788 if s0 else tmp4771)
tmp4786 = (tmp4787 if s1 else tmp4771)
tmp4781 = (tmp4782 if s2 else tmp4786)
tmp4772 = (tmp4773 if s3 else tmp4781)
tmp4767 = (tmp4768 if s4 else tmp4772)
tmp4766 = (tmp4767 if s6 else tmp4772)
tmp4805 = (1 if action1_1 else 0)
tmp4804 = (1 if action2_1 else tmp4805)
tmp4803 = (1 if action3_1 else tmp4804)
tmp4802 = (tmp4803 if action4_1 else 0)
tmp4810 = (1 - (1 if action1_1 else 0))
tmp4809 = (tmp4805 if action2_1 else tmp4810)
tmp4811 = (1 if action2_1 else tmp4810)
tmp4808 = (tmp4809 if action3_1 else tmp4811)
tmp4807 = (1 if action4_1 else tmp4808)
tmp4812 = (1 - (tmp4803 if action4_1 else 0))
tmp4806 = (1 - (tmp4807 if oxygen_low else tmp4812))
tmp4801 = (tmp4802 if oxygen_full else tmp4806)
tmp4814 = (1 if oxygen_low else tmp4802)
tmp4813 = (tmp4802 if oxygen_full else tmp4814)
tmp4800 = (tmp4801 if k2 else tmp4813)
tmp4817 = (1 - (tmp4802 if oxygen_low else tmp4812))
tmp4816 = (tmp4802 if oxygen_full else tmp4817)
tmp4815 = (tmp4816 if k2 else tmp4813)
tmp4799 = (tmp4800 if depth7 else tmp4815)
tmp4798 = (tmp4799 if depth6 else tmp4815)
tmp4827 = (1 - (tmp4809 if action3_1 else tmp4811))
tmp4826 = (1 - (tmp4803 if action4_1 else tmp4827))
tmp4825 = (1 - (tmp4802 if oxygen_low else tmp4826))
tmp4824 = (tmp4802 if oxygen_full else tmp4825)
tmp4830 = (tmp4803 if action4_1 else tmp4827)
tmp4829 = (1 if oxygen_low else tmp4830)
tmp4828 = (tmp4802 if oxygen_full else tmp4829)
tmp4823 = (tmp4824 if k2 else tmp4828)
tmp4822 = (tmp4815 if diver_found else tmp4823)
tmp4821 = (tmp4815 if depth7 else tmp4822)
tmp4820 = (tmp4815 if depth6 else tmp4821)
tmp4819 = (tmp4798 if depth5 else tmp4820)
tmp4818 = (tmp4798 if depth4 else tmp4819)
tmp4797 = (tmp4798 if depth3 else tmp4818)
tmp4833 = (tmp4798 if depth5 else tmp4815)
tmp4832 = (tmp4798 if depth4 else tmp4833)
tmp4831 = (tmp4832 if depth3 else tmp4818)
tmp4796 = (tmp4797 if depth2 else tmp4831)
tmp4840 = (tmp4800 if k1 else tmp4815)
tmp4839 = (tmp4840 if depth7 else tmp4815)
tmp4838 = (tmp4839 if depth6 else tmp4815)
tmp4837 = (tmp4798 if depth5 else tmp4838)
tmp4836 = (tmp4798 if depth4 else tmp4837)
tmp4835 = (tmp4836 if depth3 else tmp4818)
tmp4834 = (tmp4835 if depth2 else tmp4818)
tmp4795 = (1 - (tmp4796 if depth1 else tmp4834))
tmp4794 = (tmp4771 if s1 else tmp4795)
tmp4793 = (tmp4771 if s2 else tmp4794)
tmp4851 = (1 - (1 if action4_1 else tmp4808))
tmp4850 = (tmp4802 if oxygen_full else tmp4851)
tmp4853 = (tmp4802 if oxygen_full else 1)
tmp4852 = (tmp4850 if k2 else tmp4853)
tmp4849 = (tmp4850 if k1 else tmp4852)
tmp4855 = (tmp4802 if oxygen_full else tmp4812)
tmp4856 = (tmp4855 if k2 else tmp4853)
tmp4854 = (tmp4855 if k1 else tmp4856)
tmp4848 = (tmp4849 if depth7 else tmp4854)
tmp4847 = (tmp4848 if depth6 else tmp4854)
tmp4858 = (tmp4847 if depth5 else tmp4854)
tmp4857 = (tmp4847 if depth4 else tmp4858)
tmp4846 = (tmp4847 if depth3 else tmp4857)
tmp4865 = (tmp4850 if k2 else tmp4855)
tmp4864 = (tmp4865 if k1 else tmp4856)
tmp4863 = (tmp4864 if depth7 else tmp4854)
tmp4862 = (tmp4863 if depth6 else tmp4854)
tmp4861 = (tmp4847 if depth5 else tmp4862)
tmp4860 = (tmp4847 if depth4 else tmp4861)
tmp4859 = (tmp4860 if depth3 else tmp4857)
tmp4845 = (tmp4846 if depth2 else tmp4859)
tmp4872 = (tmp4865 if k1 else tmp4852)
tmp4871 = (tmp4872 if depth7 else tmp4854)
tmp4870 = (tmp4871 if depth6 else tmp4854)
tmp4869 = (tmp4847 if depth5 else tmp4870)
tmp4868 = (tmp4847 if depth4 else tmp4869)
tmp4867 = (tmp4868 if depth3 else tmp4857)
tmp4866 = (tmp4867 if depth2 else tmp4857)
tmp4844 = (tmp4845 if depth1 else tmp4866)
tmp4877 = (tmp4850 if depth7 else tmp4855)
tmp4876 = (tmp4877 if depth6 else tmp4855)
tmp4879 = (tmp4876 if depth5 else tmp4855)
tmp4878 = (tmp4876 if depth4 else tmp4879)
tmp4875 = (tmp4876 if depth3 else tmp4878)
tmp4884 = (tmp4865 if depth7 else tmp4855)
tmp4883 = (tmp4884 if depth6 else tmp4855)
tmp4882 = (tmp4876 if depth5 else tmp4883)
tmp4881 = (tmp4876 if depth4 else tmp4882)
tmp4880 = (tmp4881 if depth3 else tmp4878)
tmp4874 = (tmp4875 if depth2 else tmp4880)
tmp4891 = (tmp4850 if k1 else tmp4865)
tmp4890 = (tmp4891 if depth7 else tmp4855)
tmp4889 = (tmp4890 if depth6 else tmp4855)
tmp4888 = (tmp4876 if depth5 else tmp4889)
tmp4887 = (tmp4876 if depth4 else tmp4888)
tmp4886 = (tmp4887 if depth3 else tmp4878)
tmp4897 = (tmp4865 if k1 else tmp4855)
tmp4896 = (tmp4897 if depth7 else tmp4855)
tmp4895 = (tmp4896 if depth6 else tmp4855)
tmp4894 = (tmp4876 if depth5 else tmp4895)
tmp4893 = (tmp4876 if depth4 else tmp4894)
tmp4892 = (tmp4893 if depth3 else tmp4878)
tmp4885 = (tmp4886 if depth2 else tmp4892)
tmp4873 = (tmp4874 if depth1 else tmp4885)
tmp4843 = (tmp4844 if s0 else tmp4873)
tmp4901 = (tmp4876 if depth3 else tmp4893)
tmp4900 = (tmp4901 if depth2 else tmp4886)
tmp4899 = (tmp4900 if depth1 else tmp4874)
tmp4904 = (tmp4876 if depth3 else tmp4881)
tmp4903 = (tmp4904 if depth2 else tmp4875)
tmp4902 = (tmp4903 if depth1 else tmp4900)
tmp4898 = (tmp4899 if s0 else tmp4902)
tmp4842 = (tmp4843 if s1 else tmp4898)
tmp4914 = (tmp4802 if oxygen_full else 0)
tmp4913 = (tmp4914 if k2 else tmp4850)
tmp4912 = (tmp4913 if k1 else tmp4850)
tmp4916 = (tmp4914 if k2 else tmp4855)
tmp4915 = (tmp4916 if k1 else tmp4855)
tmp4911 = (tmp4912 if depth7 else tmp4915)
tmp4910 = (tmp4911 if depth6 else tmp4915)
tmp4921 = (tmp4913 if k1 else tmp4865)
tmp4920 = (tmp4921 if depth7 else tmp4915)
tmp4919 = (tmp4920 if depth6 else tmp4915)
tmp4918 = (tmp4910 if depth5 else tmp4919)
tmp4917 = (tmp4910 if depth4 else tmp4918)
tmp4909 = (tmp4910 if depth3 else tmp4917)
tmp4924 = (tmp4910 if depth5 else tmp4915)
tmp4923 = (tmp4910 if depth4 else tmp4924)
tmp4922 = (tmp4910 if depth3 else tmp4923)
tmp4908 = (tmp4909 if depth2 else tmp4922)
tmp4931 = (tmp4916 if k1 else tmp4865)
tmp4930 = (tmp4931 if depth7 else tmp4915)
tmp4929 = (tmp4930 if depth6 else tmp4915)
tmp4928 = (tmp4910 if depth5 else tmp4929)
tmp4927 = (tmp4910 if depth4 else tmp4928)
tmp4926 = (tmp4910 if depth3 else tmp4927)
tmp4925 = (tmp4926 if depth2 else tmp4922)
tmp4907 = (tmp4908 if depth1 else tmp4925)
tmp4935 = (tmp4913 if depth7 else tmp4916)
tmp4934 = (tmp4935 if depth6 else tmp4916)
tmp4938 = (tmp4934 if depth5 else tmp4916)
tmp4937 = (tmp4934 if depth4 else tmp4938)
tmp4936 = (tmp4934 if depth3 else tmp4937)
tmp4933 = (tmp4934 if depth2 else tmp4936)
tmp4945 = (tmp4913 if k1 else tmp4916)
tmp4944 = (tmp4945 if depth7 else tmp4916)
tmp4943 = (tmp4944 if depth6 else tmp4916)
tmp4942 = (tmp4934 if depth5 else tmp4943)
tmp4941 = (tmp4934 if depth4 else tmp4942)
tmp4940 = (tmp4934 if depth3 else tmp4941)
tmp4939 = (tmp4940 if depth2 else tmp4936)
tmp4932 = (tmp4933 if depth1 else tmp4939)
tmp4906 = (tmp4907 if s0 else tmp4932)
tmp4956 = (tmp4802 if oxygen_full else tmp4807)
tmp4955 = (tmp4956 if k2 else tmp4914)
tmp4954 = (tmp4955 if k1 else tmp4913)
tmp4958 = (tmp4802 if k2 else tmp4914)
tmp4957 = (tmp4958 if k1 else tmp4916)
tmp4953 = (tmp4954 if depth7 else tmp4957)
tmp4960 = (tmp4955 if k1 else tmp4916)
tmp4959 = (tmp4960 if depth7 else tmp4957)
tmp4952 = (tmp4953 if depth6 else tmp4959)
tmp4961 = (tmp4953 if depth6 else tmp4957)
tmp4951 = (tmp4952 if depth5 else tmp4961)
tmp4950 = (tmp4951 if depth4 else tmp4961)
tmp4949 = (tmp4950 if depth3 else tmp4961)
tmp4965 = (tmp4959 if depth6 else tmp4957)
tmp4964 = (tmp4961 if depth5 else tmp4965)
tmp4963 = (tmp4961 if depth4 else tmp4964)
tmp4962 = (tmp4961 if depth3 else tmp4963)
tmp4948 = (tmp4949 if depth2 else tmp4962)
tmp4966 = (tmp4961 if depth2 else tmp4962)
tmp4947 = (tmp4948 if depth1 else tmp4966)
tmp4972 = (tmp4955 if depth7 else tmp4958)
tmp4973 = (tmp4972 if depth6 else tmp4958)
tmp4971 = (tmp4972 if depth5 else tmp4973)
tmp4970 = (tmp4971 if depth4 else tmp4973)
tmp4969 = (tmp4970 if depth3 else tmp4973)
tmp4968 = (tmp4969 if depth2 else tmp4973)
tmp4980 = (tmp4955 if k1 else tmp4958)
tmp4979 = (tmp4980 if depth7 else tmp4958)
tmp4978 = (tmp4972 if depth6 else tmp4979)
tmp4977 = (tmp4978 if depth5 else tmp4973)
tmp4976 = (tmp4977 if depth4 else tmp4973)
tmp4975 = (tmp4976 if depth3 else tmp4973)
tmp4974 = (tmp4975 if depth2 else tmp4973)
tmp4967 = (tmp4968 if depth1 else tmp4974)
tmp4946 = (tmp4947 if s0 else tmp4967)
tmp4905 = (tmp4906 if s1 else tmp4946)
tmp4841 = (1 - (tmp4842 if s2 else tmp4905))
tmp4792 = (tmp4793 if s3 else tmp4841)
tmp4791 = (tmp4772 if s4 else tmp4792)
tmp4992 = (tmp4956 if k1 else tmp4955)
tmp4993 = (tmp4802 if k1 else tmp4958)
tmp4991 = (tmp4992 if depth7 else tmp4993)
tmp4994 = (tmp4991 if depth6 else tmp4993)
tmp4990 = (tmp4991 if depth5 else tmp4994)
tmp4989 = (tmp4990 if depth4 else tmp4994)
tmp4988 = (tmp4989 if depth3 else tmp4994)
tmp5001 = (tmp4956 if k2 else tmp4802)
tmp5000 = (tmp5001 if k1 else tmp4958)
tmp4999 = (tmp5000 if depth7 else tmp4993)
tmp4998 = (tmp4991 if depth6 else tmp4999)
tmp4997 = (tmp4998 if depth5 else tmp4994)
tmp4996 = (tmp4997 if depth4 else tmp4994)
tmp4995 = (tmp4996 if depth3 else tmp4994)
tmp4987 = (tmp4988 if depth2 else tmp4995)
tmp5008 = (tmp5001 if k1 else tmp4955)
tmp5007 = (tmp5008 if depth7 else tmp4993)
tmp5006 = (tmp4991 if depth6 else tmp5007)
tmp5005 = (tmp5006 if depth5 else tmp4994)
tmp5004 = (tmp5005 if depth4 else tmp4994)
tmp5003 = (tmp5004 if depth3 else tmp4994)
tmp5002 = (tmp5003 if depth2 else tmp4994)
tmp4986 = (tmp4987 if depth1 else tmp5002)
tmp5014 = (tmp4956 if depth7 else tmp4802)
tmp5015 = (tmp5014 if depth6 else tmp4802)
tmp5013 = (tmp5014 if depth5 else tmp5015)
tmp5012 = (tmp5013 if depth4 else tmp5015)
tmp5011 = (tmp5012 if depth3 else tmp5015)
tmp5020 = (tmp5001 if depth7 else tmp4802)
tmp5019 = (tmp5014 if depth6 else tmp5020)
tmp5018 = (tmp5019 if depth5 else tmp5015)
tmp5017 = (tmp5018 if depth4 else tmp5015)
tmp5016 = (tmp5017 if depth3 else tmp5015)
tmp5010 = (tmp5011 if depth2 else tmp5016)
tmp5027 = (tmp4956 if k1 else tmp5001)
tmp5026 = (tmp5027 if depth7 else tmp4802)
tmp5025 = (tmp5014 if depth6 else tmp5026)
tmp5024 = (tmp5025 if depth5 else tmp5015)
tmp5023 = (tmp5024 if depth4 else tmp5015)
tmp5022 = (tmp5023 if depth3 else tmp5015)
tmp5033 = (tmp5001 if k1 else tmp4802)
tmp5032 = (tmp5033 if depth7 else tmp4802)
tmp5031 = (tmp5014 if depth6 else tmp5032)
tmp5030 = (tmp5031 if depth5 else tmp5015)
tmp5029 = (tmp5030 if depth4 else tmp5015)
tmp5028 = (tmp5029 if depth3 else tmp5015)
tmp5021 = (tmp5022 if depth2 else tmp5028)
tmp5009 = (tmp5010 if depth1 else tmp5021)
tmp4985 = (tmp4986 if s0 else tmp5009)
tmp5037 = (tmp5012 if depth3 else tmp5029)
tmp5036 = (tmp5037 if depth2 else tmp5022)
tmp5035 = (tmp5036 if depth1 else tmp5010)
tmp5040 = (tmp5012 if depth3 else tmp5017)
tmp5039 = (tmp5040 if depth2 else tmp5011)
tmp5038 = (tmp5039 if depth1 else tmp5036)
tmp5034 = (tmp5035 if s0 else tmp5038)
tmp4984 = (tmp4985 if s1 else tmp5034)
tmp5050 = (tmp4853 if k2 else tmp4956)
tmp5049 = (tmp5050 if k1 else tmp4956)
tmp5052 = (tmp4853 if k2 else tmp4802)
tmp5051 = (tmp5052 if k1 else tmp4802)
tmp5048 = (tmp5049 if depth7 else tmp5051)
tmp5053 = (tmp5048 if depth6 else tmp5051)
tmp5047 = (tmp5048 if depth5 else tmp5053)
tmp5046 = (tmp5047 if depth4 else tmp5053)
tmp5058 = (tmp5050 if k1 else tmp5001)
tmp5057 = (tmp5058 if depth7 else tmp5051)
tmp5056 = (tmp5048 if depth6 else tmp5057)
tmp5055 = (tmp5056 if depth5 else tmp5053)
tmp5054 = (tmp5055 if depth4 else tmp5053)
tmp5045 = (tmp5046 if depth3 else tmp5054)
tmp5059 = (tmp5046 if depth3 else tmp5053)
tmp5044 = (tmp5045 if depth2 else tmp5059)
tmp5066 = (tmp5052 if k1 else tmp5001)
tmp5065 = (tmp5066 if depth7 else tmp5051)
tmp5064 = (tmp5048 if depth6 else tmp5065)
tmp5063 = (tmp5064 if depth5 else tmp5053)
tmp5062 = (tmp5063 if depth4 else tmp5053)
tmp5061 = (tmp5046 if depth3 else tmp5062)
tmp5060 = (tmp5061 if depth2 else tmp5059)
tmp5043 = (tmp5044 if depth1 else tmp5060)
tmp5071 = (tmp5050 if depth7 else tmp5052)
tmp5072 = (tmp5071 if depth6 else tmp5052)
tmp5070 = (tmp5071 if depth5 else tmp5072)
tmp5069 = (tmp5070 if depth4 else tmp5072)
tmp5073 = (tmp5069 if depth3 else tmp5072)
tmp5068 = (tmp5069 if depth2 else tmp5073)
tmp5080 = (tmp5050 if k1 else tmp5052)
tmp5079 = (tmp5080 if depth7 else tmp5052)
tmp5078 = (tmp5071 if depth6 else tmp5079)
tmp5077 = (tmp5078 if depth5 else tmp5072)
tmp5076 = (tmp5077 if depth4 else tmp5072)
tmp5075 = (tmp5069 if depth3 else tmp5076)
tmp5074 = (tmp5075 if depth2 else tmp5073)
tmp5067 = (tmp5068 if depth1 else tmp5074)
tmp5042 = (tmp5043 if s0 else tmp5067)
tmp5088 = (tmp4852 if k1 else tmp5050)
tmp5089 = (tmp4856 if k1 else tmp5052)
tmp5087 = (tmp5088 if depth7 else tmp5089)
tmp5090 = (tmp5087 if depth6 else tmp5089)
tmp5086 = (tmp5087 if depth5 else tmp5090)
tmp5094 = (tmp4852 if k1 else tmp5052)
tmp5093 = (tmp5094 if depth7 else tmp5089)
tmp5092 = (tmp5087 if depth6 else tmp5093)
tmp5091 = (tmp5092 if depth5 else tmp5090)
tmp5085 = (tmp5086 if depth4 else tmp5091)
tmp5095 = (tmp5086 if depth4 else tmp5090)
tmp5084 = (tmp5085 if depth3 else tmp5095)
tmp5097 = (tmp5091 if depth4 else tmp5090)
tmp5096 = (tmp5095 if depth3 else tmp5097)
tmp5083 = (tmp5084 if depth2 else tmp5096)
tmp5098 = (tmp5095 if depth2 else tmp5096)
tmp5082 = (tmp5083 if depth1 else tmp5098)
tmp5103 = (tmp4852 if depth7 else tmp4856)
tmp5104 = (tmp5103 if depth6 else tmp4856)
tmp5102 = (tmp5103 if depth5 else tmp5104)
tmp5105 = (tmp5102 if depth4 else tmp5104)
tmp5101 = (tmp5102 if depth3 else tmp5105)
tmp5100 = (tmp5101 if depth2 else tmp5105)
tmp5112 = (tmp4852 if k1 else tmp4856)
tmp5111 = (tmp5112 if depth7 else tmp4856)
tmp5110 = (tmp5103 if depth6 else tmp5111)
tmp5109 = (tmp5110 if depth5 else tmp5104)
tmp5108 = (tmp5102 if depth4 else tmp5109)
tmp5107 = (tmp5108 if depth3 else tmp5105)
tmp5106 = (tmp5107 if depth2 else tmp5105)
tmp5099 = (tmp5100 if depth1 else tmp5106)
tmp5081 = (tmp5082 if s0 else tmp5099)
tmp5041 = (tmp5042 if s1 else tmp5081)
tmp4983 = (tmp4984 if s2 else tmp5041)
tmp5119 = (tmp4848 if depth5 else tmp4847)
tmp5120 = (tmp5119 if depth4 else tmp4847)
tmp5118 = (tmp5119 if depth3 else tmp5120)
tmp5124 = (tmp4848 if depth6 else tmp4863)
tmp5123 = (tmp5124 if depth5 else tmp4847)
tmp5122 = (tmp5119 if depth4 else tmp5123)
tmp5121 = (tmp5122 if depth3 else tmp5120)
tmp5117 = (tmp5118 if depth2 else tmp5121)
tmp5129 = (tmp4848 if depth6 else tmp4871)
tmp5128 = (tmp5129 if depth5 else tmp4847)
tmp5127 = (tmp5119 if depth4 else tmp5128)
tmp5126 = (tmp5127 if depth3 else tmp5120)
tmp5125 = (tmp5126 if depth2 else tmp5120)
tmp5116 = (tmp5117 if depth1 else tmp5125)
tmp5133 = (tmp4877 if depth5 else tmp4876)
tmp5134 = (tmp5133 if depth4 else tmp4876)
tmp5132 = (tmp5133 if depth3 else tmp5134)
tmp5138 = (tmp4877 if depth6 else tmp4884)
tmp5137 = (tmp5138 if depth5 else tmp4876)
tmp5136 = (tmp5133 if depth4 else tmp5137)
tmp5135 = (tmp5136 if depth3 else tmp5134)
tmp5131 = (tmp5132 if depth2 else tmp5135)
tmp5143 = (tmp4877 if depth6 else tmp4890)
tmp5142 = (tmp5143 if depth5 else tmp4876)
tmp5141 = (tmp5133 if depth4 else tmp5142)
tmp5140 = (tmp5141 if depth3 else tmp5134)
tmp5147 = (tmp4877 if depth6 else tmp4896)
tmp5146 = (tmp5147 if depth5 else tmp4876)
tmp5145 = (tmp5133 if depth4 else tmp5146)
tmp5144 = (tmp5145 if depth3 else tmp5134)
tmp5139 = (tmp5140 if depth2 else tmp5144)
tmp5130 = (tmp5131 if depth1 else tmp5139)
tmp5115 = (tmp5116 if s0 else tmp5130)
tmp5151 = (tmp5133 if depth3 else tmp5145)
tmp5150 = (tmp5151 if depth2 else tmp5140)
tmp5149 = (tmp5150 if depth1 else tmp5131)
tmp5154 = (tmp5133 if depth3 else tmp5136)
tmp5153 = (tmp5154 if depth2 else tmp5132)
tmp5152 = (tmp5153 if depth1 else tmp5150)
tmp5148 = (tmp5149 if s0 else tmp5152)
tmp5114 = (tmp5115 if s1 else tmp5148)
tmp5160 = (tmp4911 if depth5 else tmp4910)
tmp5163 = (tmp4911 if depth6 else tmp4920)
tmp5162 = (tmp5163 if depth5 else tmp4910)
tmp5161 = (tmp5160 if depth4 else tmp5162)
tmp5159 = (tmp5160 if depth3 else tmp5161)
tmp5165 = (tmp5160 if depth4 else tmp4910)
tmp5164 = (tmp5160 if depth3 else tmp5165)
tmp5158 = (tmp5159 if depth2 else tmp5164)
tmp5170 = (tmp4911 if depth6 else tmp4930)
tmp5169 = (tmp5170 if depth5 else tmp4910)
tmp5168 = (tmp5160 if depth4 else tmp5169)
tmp5167 = (tmp5160 if depth3 else tmp5168)
tmp5166 = (tmp5167 if depth2 else tmp5164)
tmp5157 = (tmp5158 if depth1 else tmp5166)
tmp5173 = (tmp4935 if depth5 else tmp4934)
tmp5175 = (tmp5173 if depth4 else tmp4934)
tmp5174 = (tmp5173 if depth3 else tmp5175)
tmp5172 = (tmp5173 if depth2 else tmp5174)
tmp5180 = (tmp4935 if depth6 else tmp4944)
tmp5179 = (tmp5180 if depth5 else tmp4934)
tmp5178 = (tmp5173 if depth4 else tmp5179)
tmp5177 = (tmp5173 if depth3 else tmp5178)
tmp5176 = (tmp5177 if depth2 else tmp5174)
tmp5171 = (tmp5172 if depth1 else tmp5176)
tmp5156 = (tmp5157 if s0 else tmp5171)
tmp5186 = (tmp4953 if depth5 else tmp4952)
tmp5187 = (tmp4953 if depth5 else tmp4961)
tmp5185 = (tmp5186 if depth4 else tmp5187)
tmp5184 = (tmp5185 if depth3 else tmp5187)
tmp5189 = (tmp5187 if depth4 else tmp4951)
tmp5188 = (tmp5187 if depth3 else tmp5189)
tmp5183 = (tmp5184 if depth2 else tmp5188)
tmp5190 = (tmp5187 if depth2 else tmp5188)
tmp5182 = (tmp5183 if depth1 else tmp5190)
tmp5194 = (tmp4972 if depth4 else tmp4971)
tmp5193 = (tmp5194 if depth3 else tmp4971)
tmp5192 = (tmp5193 if depth2 else tmp4971)
tmp5198 = (tmp4972 if depth5 else tmp4978)
tmp5197 = (tmp5198 if depth4 else tmp4971)
tmp5196 = (tmp5197 if depth3 else tmp4971)
tmp5195 = (tmp5196 if depth2 else tmp4971)
tmp5191 = (tmp5192 if depth1 else tmp5195)
tmp5181 = (tmp5182 if s0 else tmp5191)
tmp5155 = (tmp5156 if s1 else tmp5181)
tmp5113 = (tmp5114 if s2 else tmp5155)
tmp4982 = (tmp4983 if s3 else tmp5113)
tmp5206 = (tmp4991 if depth4 else tmp4990)
tmp5205 = (tmp5206 if depth3 else tmp4990)
tmp5209 = (tmp4991 if depth5 else tmp4998)
tmp5208 = (tmp5209 if depth4 else tmp4990)
tmp5207 = (tmp5208 if depth3 else tmp4990)
tmp5204 = (tmp5205 if depth2 else tmp5207)
tmp5213 = (tmp4991 if depth5 else tmp5006)
tmp5212 = (tmp5213 if depth4 else tmp4990)
tmp5211 = (tmp5212 if depth3 else tmp4990)
tmp5210 = (tmp5211 if depth2 else tmp4990)
tmp5203 = (tmp5204 if depth1 else tmp5210)
tmp5217 = (tmp5014 if depth4 else tmp5013)
tmp5216 = (tmp5217 if depth3 else tmp5013)
tmp5220 = (tmp5014 if depth5 else tmp5019)
tmp5219 = (tmp5220 if depth4 else tmp5013)
tmp5218 = (tmp5219 if depth3 else tmp5013)
tmp5215 = (tmp5216 if depth2 else tmp5218)
tmp5224 = (tmp5014 if depth5 else tmp5025)
tmp5223 = (tmp5224 if depth4 else tmp5013)
tmp5222 = (tmp5223 if depth3 else tmp5013)
tmp5227 = (tmp5014 if depth5 else tmp5031)
tmp5226 = (tmp5227 if depth4 else tmp5013)
tmp5225 = (tmp5226 if depth3 else tmp5013)
tmp5221 = (tmp5222 if depth2 else tmp5225)
tmp5214 = (tmp5215 if depth1 else tmp5221)
tmp5202 = (tmp5203 if s0 else tmp5214)
tmp5231 = (tmp5217 if depth3 else tmp5226)
tmp5230 = (tmp5231 if depth2 else tmp5222)
tmp5229 = (tmp5230 if depth1 else tmp5215)
tmp5234 = (tmp5217 if depth3 else tmp5219)
tmp5233 = (tmp5234 if depth2 else tmp5216)
tmp5232 = (tmp5233 if depth1 else tmp5230)
tmp5228 = (tmp5229 if s0 else tmp5232)
tmp5201 = (tmp5202 if s1 else tmp5228)
tmp5240 = (tmp5048 if depth4 else tmp5047)
tmp5242 = (tmp5048 if depth5 else tmp5056)
tmp5241 = (tmp5242 if depth4 else tmp5047)
tmp5239 = (tmp5240 if depth3 else tmp5241)
tmp5243 = (tmp5240 if depth3 else tmp5047)
tmp5238 = (tmp5239 if depth2 else tmp5243)
tmp5247 = (tmp5048 if depth5 else tmp5064)
tmp5246 = (tmp5247 if depth4 else tmp5047)
tmp5245 = (tmp5240 if depth3 else tmp5246)
tmp5244 = (tmp5245 if depth2 else tmp5243)
tmp5237 = (tmp5238 if depth1 else tmp5244)
tmp5250 = (tmp5071 if depth4 else tmp5070)
tmp5251 = (tmp5250 if depth3 else tmp5070)
tmp5249 = (tmp5250 if depth2 else tmp5251)
tmp5255 = (tmp5071 if depth5 else tmp5078)
tmp5254 = (tmp5255 if depth4 else tmp5070)
tmp5253 = (tmp5250 if depth3 else tmp5254)
tmp5252 = (tmp5253 if depth2 else tmp5251)
tmp5248 = (tmp5249 if depth1 else tmp5252)
tmp5236 = (tmp5237 if s0 else tmp5248)
tmp5261 = (tmp5087 if depth5 else tmp5092)
tmp5260 = (tmp5087 if depth4 else tmp5261)
tmp5262 = (tmp5087 if depth4 else tmp5086)
tmp5259 = (tmp5260 if depth3 else tmp5262)
tmp5264 = (tmp5261 if depth4 else tmp5086)
tmp5263 = (tmp5262 if depth3 else tmp5264)
tmp5258 = (tmp5259 if depth2 else tmp5263)
tmp5265 = (tmp5262 if depth2 else tmp5263)
tmp5257 = (tmp5258 if depth1 else tmp5265)
tmp5269 = (tmp5103 if depth4 else tmp5102)
tmp5268 = (tmp5103 if depth3 else tmp5269)
tmp5267 = (tmp5268 if depth2 else tmp5269)
tmp5273 = (tmp5103 if depth5 else tmp5110)
tmp5272 = (tmp5103 if depth4 else tmp5273)
tmp5271 = (tmp5272 if depth3 else tmp5269)
tmp5270 = (tmp5271 if depth2 else tmp5269)
tmp5266 = (tmp5267 if depth1 else tmp5270)
tmp5256 = (tmp5257 if s0 else tmp5266)
tmp5235 = (tmp5236 if s1 else tmp5256)
tmp5200 = (tmp5201 if s2 else tmp5235)
tmp5280 = (tmp4848 if depth4 else tmp5119)
tmp5279 = (tmp4848 if depth3 else tmp5280)
tmp5283 = (tmp4848 if depth5 else tmp5124)
tmp5282 = (tmp4848 if depth4 else tmp5283)
tmp5281 = (tmp5282 if depth3 else tmp5280)
tmp5278 = (tmp5279 if depth2 else tmp5281)
tmp5287 = (tmp4848 if depth5 else tmp5129)
tmp5286 = (tmp4848 if depth4 else tmp5287)
tmp5285 = (tmp5286 if depth3 else tmp5280)
tmp5284 = (tmp5285 if depth2 else tmp5280)
tmp5277 = (tmp5278 if depth1 else tmp5284)
tmp5291 = (tmp4877 if depth4 else tmp5133)
tmp5290 = (tmp4877 if depth3 else tmp5291)
tmp5294 = (tmp4877 if depth5 else tmp5138)
tmp5293 = (tmp4877 if depth4 else tmp5294)
tmp5292 = (tmp5293 if depth3 else tmp5291)
tmp5289 = (tmp5290 if depth2 else tmp5292)
tmp5298 = (tmp4877 if depth5 else tmp5143)
tmp5297 = (tmp4877 if depth4 else tmp5298)
tmp5296 = (tmp5297 if depth3 else tmp5291)
tmp5301 = (tmp4877 if depth5 else tmp5147)
tmp5300 = (tmp4877 if depth4 else tmp5301)
tmp5299 = (tmp5300 if depth3 else tmp5291)
tmp5295 = (tmp5296 if depth2 else tmp5299)
tmp5288 = (tmp5289 if depth1 else tmp5295)
tmp5276 = (tmp5277 if s0 else tmp5288)
tmp5305 = (tmp4877 if depth3 else tmp5300)
tmp5304 = (tmp5305 if depth2 else tmp5296)
tmp5303 = (tmp5304 if depth1 else tmp5289)
tmp5308 = (tmp4877 if depth3 else tmp5293)
tmp5307 = (tmp5308 if depth2 else tmp5290)
tmp5306 = (tmp5307 if depth1 else tmp5304)
tmp5302 = (tmp5303 if s0 else tmp5306)
tmp5275 = (tmp5276 if s1 else tmp5302)
tmp5315 = (tmp4911 if depth5 else tmp5163)
tmp5314 = (tmp4911 if depth4 else tmp5315)
tmp5313 = (tmp4911 if depth3 else tmp5314)
tmp5317 = (tmp4911 if depth4 else tmp5160)
tmp5316 = (tmp4911 if depth3 else tmp5317)
tmp5312 = (tmp5313 if depth2 else tmp5316)
tmp5321 = (tmp4911 if depth5 else tmp5170)
tmp5320 = (tmp4911 if depth4 else tmp5321)
tmp5319 = (tmp4911 if depth3 else tmp5320)
tmp5318 = (tmp5319 if depth2 else tmp5316)
tmp5311 = (tmp5312 if depth1 else tmp5318)
tmp5325 = (tmp4935 if depth4 else tmp5173)
tmp5324 = (tmp4935 if depth3 else tmp5325)
tmp5323 = (tmp4935 if depth2 else tmp5324)
tmp5329 = (tmp4935 if depth5 else tmp5180)
tmp5328 = (tmp4935 if depth4 else tmp5329)
tmp5327 = (tmp4935 if depth3 else tmp5328)
tmp5326 = (tmp5327 if depth2 else tmp5324)
tmp5322 = (tmp5323 if depth1 else tmp5326)
tmp5310 = (tmp5311 if s0 else tmp5322)
tmp5337 = (tmp4954 if depth7 else tmp4960)
tmp5336 = (tmp5337 if depth6 else tmp4953)
tmp5335 = (tmp5336 if depth5 else tmp4953)
tmp5334 = (tmp5335 if depth4 else tmp4953)
tmp5333 = (tmp5334 if depth3 else tmp4953)
tmp5339 = (tmp4953 if depth4 else tmp5186)
tmp5338 = (tmp4953 if depth3 else tmp5339)
tmp5332 = (tmp5333 if depth2 else tmp5338)
tmp5340 = (tmp4953 if depth2 else tmp5338)
tmp5331 = (tmp5332 if depth1 else tmp5340)
tmp5346 = (tmp4955 if depth6 else tmp4972)
tmp5345 = (tmp5346 if depth5 else tmp4972)
tmp5344 = (tmp5345 if depth4 else tmp4972)
tmp5343 = (tmp5344 if depth3 else tmp4972)
tmp5342 = (tmp5343 if depth2 else tmp4972)
tmp5352 = (tmp4955 if depth7 else tmp4980)
tmp5351 = (tmp5352 if depth6 else tmp4972)
tmp5350 = (tmp5351 if depth5 else tmp4972)
tmp5349 = (tmp5350 if depth4 else tmp4972)
tmp5348 = (tmp5349 if depth3 else tmp4972)
tmp5347 = (tmp5348 if depth2 else tmp4972)
tmp5341 = (tmp5342 if depth1 else tmp5347)
tmp5330 = (tmp5331 if s0 else tmp5341)
tmp5309 = (tmp5310 if s1 else tmp5330)
tmp5274 = (tmp5275 if s2 else tmp5309)
tmp5199 = (tmp5200 if s3 else tmp5274)
tmp4981 = (1 - (tmp4982 if s4 else tmp5199))
tmp4790 = (tmp4791 if s5 else tmp4981)
tmp5364 = (tmp4992 if depth6 else tmp4991)
tmp5363 = (tmp5364 if depth5 else tmp4991)
tmp5362 = (tmp5363 if depth4 else tmp4991)
tmp5361 = (tmp5362 if depth3 else tmp4991)
tmp5369 = (tmp4992 if depth7 else tmp5000)
tmp5368 = (tmp5369 if depth6 else tmp4991)
tmp5367 = (tmp5368 if depth5 else tmp4991)
tmp5366 = (tmp5367 if depth4 else tmp4991)
tmp5365 = (tmp5366 if depth3 else tmp4991)
tmp5360 = (tmp5361 if depth2 else tmp5365)
tmp5375 = (tmp4992 if depth7 else tmp5008)
tmp5374 = (tmp5375 if depth6 else tmp4991)
tmp5373 = (tmp5374 if depth5 else tmp4991)
tmp5372 = (tmp5373 if depth4 else tmp4991)
tmp5371 = (tmp5372 if depth3 else tmp4991)
tmp5370 = (tmp5371 if depth2 else tmp4991)
tmp5359 = (tmp5360 if depth1 else tmp5370)
tmp5381 = (tmp4956 if depth6 else tmp5014)
tmp5380 = (tmp5381 if depth5 else tmp5014)
tmp5379 = (tmp5380 if depth4 else tmp5014)
tmp5378 = (tmp5379 if depth3 else tmp5014)
tmp5386 = (tmp4956 if depth7 else tmp5001)
tmp5385 = (tmp5386 if depth6 else tmp5014)
tmp5384 = (tmp5385 if depth5 else tmp5014)
tmp5383 = (tmp5384 if depth4 else tmp5014)
tmp5382 = (tmp5383 if depth3 else tmp5014)
tmp5377 = (tmp5378 if depth2 else tmp5382)
tmp5392 = (tmp4956 if depth7 else tmp5027)
tmp5391 = (tmp5392 if depth6 else tmp5014)
tmp5390 = (tmp5391 if depth5 else tmp5014)
tmp5389 = (tmp5390 if depth4 else tmp5014)
tmp5388 = (tmp5389 if depth3 else tmp5014)
tmp5397 = (tmp4956 if depth7 else tmp5033)
tmp5396 = (tmp5397 if depth6 else tmp5014)
tmp5395 = (tmp5396 if depth5 else tmp5014)
tmp5394 = (tmp5395 if depth4 else tmp5014)
tmp5393 = (tmp5394 if depth3 else tmp5014)
tmp5387 = (tmp5388 if depth2 else tmp5393)
tmp5376 = (tmp5377 if depth1 else tmp5387)
tmp5358 = (tmp5359 if s0 else tmp5376)
tmp5401 = (tmp5379 if depth3 else tmp5394)
tmp5400 = (tmp5401 if depth2 else tmp5388)
tmp5399 = (tmp5400 if depth1 else tmp5377)
tmp5404 = (tmp5379 if depth3 else tmp5383)
tmp5403 = (tmp5404 if depth2 else tmp5378)
tmp5402 = (tmp5403 if depth1 else tmp5400)
tmp5398 = (tmp5399 if s0 else tmp5402)
tmp5357 = (tmp5358 if s1 else tmp5398)
tmp5412 = (tmp5049 if depth6 else tmp5048)
tmp5411 = (tmp5412 if depth5 else tmp5048)
tmp5410 = (tmp5411 if depth4 else tmp5048)
tmp5416 = (tmp5049 if depth7 else tmp5058)
tmp5415 = (tmp5416 if depth6 else tmp5048)
tmp5414 = (tmp5415 if depth5 else tmp5048)
tmp5413 = (tmp5414 if depth4 else tmp5048)
tmp5409 = (tmp5410 if depth3 else tmp5413)
tmp5417 = (tmp5410 if depth3 else tmp5048)
tmp5408 = (tmp5409 if depth2 else tmp5417)
tmp5423 = (tmp5049 if depth7 else tmp5066)
tmp5422 = (tmp5423 if depth6 else tmp5048)
tmp5421 = (tmp5422 if depth5 else tmp5048)
tmp5420 = (tmp5421 if depth4 else tmp5048)
tmp5419 = (tmp5410 if depth3 else tmp5420)
tmp5418 = (tmp5419 if depth2 else tmp5417)
tmp5407 = (tmp5408 if depth1 else tmp5418)
tmp5428 = (tmp5050 if depth6 else tmp5071)
tmp5427 = (tmp5428 if depth5 else tmp5071)
tmp5426 = (tmp5427 if depth4 else tmp5071)
tmp5429 = (tmp5426 if depth3 else tmp5071)
tmp5425 = (tmp5426 if depth2 else tmp5429)
tmp5435 = (tmp5050 if depth7 else tmp5080)
tmp5434 = (tmp5435 if depth6 else tmp5071)
tmp5433 = (tmp5434 if depth5 else tmp5071)
tmp5432 = (tmp5433 if depth4 else tmp5071)
tmp5431 = (tmp5426 if depth3 else tmp5432)
tmp5430 = (tmp5431 if depth2 else tmp5429)
tmp5424 = (tmp5425 if depth1 else tmp5430)
tmp5406 = (tmp5407 if s0 else tmp5424)
tmp5442 = (tmp5088 if depth6 else tmp5087)
tmp5441 = (tmp5442 if depth5 else tmp5087)
tmp5445 = (tmp5088 if depth7 else tmp5094)
tmp5444 = (tmp5445 if depth6 else tmp5087)
tmp5443 = (tmp5444 if depth5 else tmp5087)
tmp5440 = (tmp5441 if depth4 else tmp5443)
tmp5446 = (tmp5441 if depth4 else tmp5087)
tmp5439 = (tmp5440 if depth3 else tmp5446)
tmp5448 = (tmp5443 if depth4 else tmp5087)
tmp5447 = (tmp5446 if depth3 else tmp5448)
tmp5438 = (tmp5439 if depth2 else tmp5447)
tmp5449 = (tmp5446 if depth2 else tmp5447)
tmp5437 = (tmp5438 if depth1 else tmp5449)
tmp5454 = (tmp4852 if depth6 else tmp5103)
tmp5453 = (tmp5454 if depth5 else tmp5103)
tmp5455 = (tmp5453 if depth4 else tmp5103)
tmp5452 = (tmp5453 if depth3 else tmp5455)
tmp5451 = (tmp5452 if depth2 else tmp5455)
tmp5461 = (tmp4852 if depth7 else tmp5112)
tmp5460 = (tmp5461 if depth6 else tmp5103)
tmp5459 = (tmp5460 if depth5 else tmp5103)
tmp5458 = (tmp5453 if depth4 else tmp5459)
tmp5457 = (tmp5458 if depth3 else tmp5455)
tmp5456 = (tmp5457 if depth2 else tmp5455)
tmp5450 = (tmp5451 if depth1 else tmp5456)
tmp5436 = (tmp5437 if s0 else tmp5450)
tmp5405 = (tmp5406 if s1 else tmp5436)
tmp5356 = (tmp5357 if s2 else tmp5405)
tmp5469 = (tmp4849 if depth6 else tmp4848)
tmp5468 = (tmp5469 if depth5 else tmp4848)
tmp5470 = (tmp5468 if depth4 else tmp4848)
tmp5467 = (tmp5468 if depth3 else tmp5470)
tmp5475 = (tmp4849 if depth7 else tmp4864)
tmp5474 = (tmp5475 if depth6 else tmp4848)
tmp5473 = (tmp5474 if depth5 else tmp4848)
tmp5472 = (tmp5468 if depth4 else tmp5473)
tmp5471 = (tmp5472 if depth3 else tmp5470)
tmp5466 = (tmp5467 if depth2 else tmp5471)
tmp5481 = (tmp4849 if depth7 else tmp4872)
tmp5480 = (tmp5481 if depth6 else tmp4848)
tmp5479 = (tmp5480 if depth5 else tmp4848)
tmp5478 = (tmp5468 if depth4 else tmp5479)
tmp5477 = (tmp5478 if depth3 else tmp5470)
tmp5476 = (tmp5477 if depth2 else tmp5470)
tmp5465 = (tmp5466 if depth1 else tmp5476)
tmp5486 = (tmp4850 if depth6 else tmp4877)
tmp5485 = (tmp5486 if depth5 else tmp4877)
tmp5487 = (tmp5485 if depth4 else tmp4877)
tmp5484 = (tmp5485 if depth3 else tmp5487)
tmp5492 = (tmp4850 if depth7 else tmp4865)
tmp5491 = (tmp5492 if depth6 else tmp4877)
tmp5490 = (tmp5491 if depth5 else tmp4877)
tmp5489 = (tmp5485 if depth4 else tmp5490)
tmp5488 = (tmp5489 if depth3 else tmp5487)
tmp5483 = (tmp5484 if depth2 else tmp5488)
tmp5498 = (tmp4850 if depth7 else tmp4891)
tmp5497 = (tmp5498 if depth6 else tmp4877)
tmp5496 = (tmp5497 if depth5 else tmp4877)
tmp5495 = (tmp5485 if depth4 else tmp5496)
tmp5494 = (tmp5495 if depth3 else tmp5487)
tmp5503 = (tmp4850 if depth7 else tmp4897)
tmp5502 = (tmp5503 if depth6 else tmp4877)
tmp5501 = (tmp5502 if depth5 else tmp4877)
tmp5500 = (tmp5485 if depth4 else tmp5501)
tmp5499 = (tmp5500 if depth3 else tmp5487)
tmp5493 = (tmp5494 if depth2 else tmp5499)
tmp5482 = (tmp5483 if depth1 else tmp5493)
tmp5464 = (tmp5465 if s0 else tmp5482)
tmp5507 = (tmp5485 if depth3 else tmp5500)
tmp5506 = (tmp5507 if depth2 else tmp5494)
tmp5505 = (tmp5506 if depth1 else tmp5483)
tmp5510 = (tmp5485 if depth3 else tmp5489)
tmp5509 = (tmp5510 if depth2 else tmp5484)
tmp5508 = (tmp5509 if depth1 else tmp5506)
tmp5504 = (tmp5505 if s0 else tmp5508)
tmp5463 = (tmp5464 if s1 else tmp5504)
tmp5517 = (tmp4912 if depth6 else tmp4911)
tmp5516 = (tmp5517 if depth5 else tmp4911)
tmp5521 = (tmp4912 if depth7 else tmp4921)
tmp5520 = (tmp5521 if depth6 else tmp4911)
tmp5519 = (tmp5520 if depth5 else tmp4911)
tmp5518 = (tmp5516 if depth4 else tmp5519)
tmp5515 = (tmp5516 if depth3 else tmp5518)
tmp5523 = (tmp5516 if depth4 else tmp4911)
tmp5522 = (tmp5516 if depth3 else tmp5523)
tmp5514 = (tmp5515 if depth2 else tmp5522)
tmp5529 = (tmp4912 if depth7 else tmp4931)
tmp5528 = (tmp5529 if depth6 else tmp4911)
tmp5527 = (tmp5528 if depth5 else tmp4911)
tmp5526 = (tmp5516 if depth4 else tmp5527)
tmp5525 = (tmp5516 if depth3 else tmp5526)
tmp5524 = (tmp5525 if depth2 else tmp5522)
tmp5513 = (tmp5514 if depth1 else tmp5524)
tmp5533 = (tmp4913 if depth6 else tmp4935)
tmp5532 = (tmp5533 if depth5 else tmp4935)
tmp5535 = (tmp5532 if depth4 else tmp4935)
tmp5534 = (tmp5532 if depth3 else tmp5535)
tmp5531 = (tmp5532 if depth2 else tmp5534)
tmp5541 = (tmp4913 if depth7 else tmp4945)
tmp5540 = (tmp5541 if depth6 else tmp4935)
tmp5539 = (tmp5540 if depth5 else tmp4935)
tmp5538 = (tmp5532 if depth4 else tmp5539)
tmp5537 = (tmp5532 if depth3 else tmp5538)
tmp5536 = (tmp5537 if depth2 else tmp5534)
tmp5530 = (tmp5531 if depth1 else tmp5536)
tmp5512 = (tmp5513 if s0 else tmp5530)
tmp5548 = (tmp4954 if depth6 else tmp4953)
tmp5547 = (tmp5548 if depth5 else tmp5336)
tmp5549 = (tmp5548 if depth5 else tmp4953)
tmp5546 = (tmp5547 if depth4 else tmp5549)
tmp5545 = (tmp5546 if depth3 else tmp5549)
tmp5551 = (tmp5549 if depth4 else tmp5335)
tmp5550 = (tmp5549 if depth3 else tmp5551)
tmp5544 = (tmp5545 if depth2 else tmp5550)
tmp5552 = (tmp5549 if depth2 else tmp5550)
tmp5543 = (tmp5544 if depth1 else tmp5552)
tmp5556 = (tmp5346 if depth4 else tmp5345)
tmp5555 = (tmp5556 if depth3 else tmp5345)
tmp5554 = (tmp5555 if depth2 else tmp5345)
tmp5560 = (tmp5346 if depth5 else tmp5351)
tmp5559 = (tmp5560 if depth4 else tmp5345)
tmp5558 = (tmp5559 if depth3 else tmp5345)
tmp5557 = (tmp5558 if depth2 else tmp5345)
tmp5553 = (tmp5554 if depth1 else tmp5557)
tmp5542 = (tmp5543 if s0 else tmp5553)
tmp5511 = (tmp5512 if s1 else tmp5542)
tmp5462 = (tmp5463 if s2 else tmp5511)
tmp5355 = (tmp5356 if s3 else tmp5462)
tmp5568 = (tmp5364 if depth4 else tmp5363)
tmp5567 = (tmp5568 if depth3 else tmp5363)
tmp5571 = (tmp5364 if depth5 else tmp5368)
tmp5570 = (tmp5571 if depth4 else tmp5363)
tmp5569 = (tmp5570 if depth3 else tmp5363)
tmp5566 = (tmp5567 if depth2 else tmp5569)
tmp5575 = (tmp5364 if depth5 else tmp5374)
tmp5574 = (tmp5575 if depth4 else tmp5363)
tmp5573 = (tmp5574 if depth3 else tmp5363)
tmp5572 = (tmp5573 if depth2 else tmp5363)
tmp5565 = (tmp5566 if depth1 else tmp5572)
tmp5579 = (tmp5381 if depth4 else tmp5380)
tmp5578 = (tmp5579 if depth3 else tmp5380)
tmp5582 = (tmp5381 if depth5 else tmp5385)
tmp5581 = (tmp5582 if depth4 else tmp5380)
tmp5580 = (tmp5581 if depth3 else tmp5380)
tmp5577 = (tmp5578 if depth2 else tmp5580)
tmp5586 = (tmp5381 if depth5 else tmp5391)
tmp5585 = (tmp5586 if depth4 else tmp5380)
tmp5584 = (tmp5585 if depth3 else tmp5380)
tmp5589 = (tmp5381 if depth5 else tmp5396)
tmp5588 = (tmp5589 if depth4 else tmp5380)
tmp5587 = (tmp5588 if depth3 else tmp5380)
tmp5583 = (tmp5584 if depth2 else tmp5587)
tmp5576 = (tmp5577 if depth1 else tmp5583)
tmp5564 = (tmp5565 if s0 else tmp5576)
tmp5593 = (tmp5579 if depth3 else tmp5588)
tmp5592 = (tmp5593 if depth2 else tmp5584)
tmp5591 = (tmp5592 if depth1 else tmp5577)
tmp5596 = (tmp5579 if depth3 else tmp5581)
tmp5595 = (tmp5596 if depth2 else tmp5578)
tmp5594 = (tmp5595 if depth1 else tmp5592)
tmp5590 = (tmp5591 if s0 else tmp5594)
tmp5563 = (tmp5564 if s1 else tmp5590)
tmp5602 = (tmp5412 if depth4 else tmp5411)
tmp5604 = (tmp5412 if depth5 else tmp5415)
tmp5603 = (tmp5604 if depth4 else tmp5411)
tmp5601 = (tmp5602 if depth3 else tmp5603)
tmp5605 = (tmp5602 if depth3 else tmp5411)
tmp5600 = (tmp5601 if depth2 else tmp5605)
tmp5609 = (tmp5412 if depth5 else tmp5422)
tmp5608 = (tmp5609 if depth4 else tmp5411)
tmp5607 = (tmp5602 if depth3 else tmp5608)
tmp5606 = (tmp5607 if depth2 else tmp5605)
tmp5599 = (tmp5600 if depth1 else tmp5606)
tmp5612 = (tmp5428 if depth4 else tmp5427)
tmp5613 = (tmp5612 if depth3 else tmp5427)
tmp5611 = (tmp5612 if depth2 else tmp5613)
tmp5617 = (tmp5428 if depth5 else tmp5434)
tmp5616 = (tmp5617 if depth4 else tmp5427)
tmp5615 = (tmp5612 if depth3 else tmp5616)
tmp5614 = (tmp5615 if depth2 else tmp5613)
tmp5610 = (tmp5611 if depth1 else tmp5614)
tmp5598 = (tmp5599 if s0 else tmp5610)
tmp5623 = (tmp5442 if depth5 else tmp5444)
tmp5622 = (tmp5442 if depth4 else tmp5623)
tmp5624 = (tmp5442 if depth4 else tmp5441)
tmp5621 = (tmp5622 if depth3 else tmp5624)
tmp5626 = (tmp5623 if depth4 else tmp5441)
tmp5625 = (tmp5624 if depth3 else tmp5626)
tmp5620 = (tmp5621 if depth2 else tmp5625)
tmp5627 = (tmp5624 if depth2 else tmp5625)
tmp5619 = (tmp5620 if depth1 else tmp5627)
tmp5631 = (tmp5454 if depth4 else tmp5453)
tmp5630 = (tmp5454 if depth3 else tmp5631)
tmp5629 = (tmp5630 if depth2 else tmp5631)
tmp5635 = (tmp5454 if depth5 else tmp5460)
tmp5634 = (tmp5454 if depth4 else tmp5635)
tmp5633 = (tmp5634 if depth3 else tmp5631)
tmp5632 = (tmp5633 if depth2 else tmp5631)
tmp5628 = (tmp5629 if depth1 else tmp5632)
tmp5618 = (tmp5619 if s0 else tmp5628)
tmp5597 = (tmp5598 if s1 else tmp5618)
tmp5562 = (tmp5563 if s2 else tmp5597)
tmp5642 = (tmp5469 if depth4 else tmp5468)
tmp5641 = (tmp5469 if depth3 else tmp5642)
tmp5645 = (tmp5469 if depth5 else tmp5474)
tmp5644 = (tmp5469 if depth4 else tmp5645)
tmp5643 = (tmp5644 if depth3 else tmp5642)
tmp5640 = (tmp5641 if depth2 else tmp5643)
tmp5649 = (tmp5469 if depth5 else tmp5480)
tmp5648 = (tmp5469 if depth4 else tmp5649)
tmp5647 = (tmp5648 if depth3 else tmp5642)
tmp5646 = (tmp5647 if depth2 else tmp5642)
tmp5639 = (tmp5640 if depth1 else tmp5646)
tmp5653 = (tmp5486 if depth4 else tmp5485)
tmp5652 = (tmp5486 if depth3 else tmp5653)
tmp5656 = (tmp5486 if depth5 else tmp5491)
tmp5655 = (tmp5486 if depth4 else tmp5656)
tmp5654 = (tmp5655 if depth3 else tmp5653)
tmp5651 = (tmp5652 if depth2 else tmp5654)
tmp5660 = (tmp5486 if depth5 else tmp5497)
tmp5659 = (tmp5486 if depth4 else tmp5660)
tmp5658 = (tmp5659 if depth3 else tmp5653)
tmp5663 = (tmp5486 if depth5 else tmp5502)
tmp5662 = (tmp5486 if depth4 else tmp5663)
tmp5661 = (tmp5662 if depth3 else tmp5653)
tmp5657 = (tmp5658 if depth2 else tmp5661)
tmp5650 = (tmp5651 if depth1 else tmp5657)
tmp5638 = (tmp5639 if s0 else tmp5650)
tmp5667 = (tmp5486 if depth3 else tmp5662)
tmp5666 = (tmp5667 if depth2 else tmp5658)
tmp5665 = (tmp5666 if depth1 else tmp5651)
tmp5670 = (tmp5486 if depth3 else tmp5655)
tmp5669 = (tmp5670 if depth2 else tmp5652)
tmp5668 = (tmp5669 if depth1 else tmp5666)
tmp5664 = (tmp5665 if s0 else tmp5668)
tmp5637 = (tmp5638 if s1 else tmp5664)
tmp5677 = (tmp5517 if depth5 else tmp5520)
tmp5676 = (tmp5517 if depth4 else tmp5677)
tmp5675 = (tmp5517 if depth3 else tmp5676)
tmp5679 = (tmp5517 if depth4 else tmp5516)
tmp5678 = (tmp5517 if depth3 else tmp5679)
tmp5674 = (tmp5675 if depth2 else tmp5678)
tmp5683 = (tmp5517 if depth5 else tmp5528)
tmp5682 = (tmp5517 if depth4 else tmp5683)
tmp5681 = (tmp5517 if depth3 else tmp5682)
tmp5680 = (tmp5681 if depth2 else tmp5678)
tmp5673 = (tmp5674 if depth1 else tmp5680)
tmp5687 = (tmp5533 if depth4 else tmp5532)
tmp5686 = (tmp5533 if depth3 else tmp5687)
tmp5685 = (tmp5533 if depth2 else tmp5686)
tmp5691 = (tmp5533 if depth5 else tmp5540)
tmp5690 = (tmp5533 if depth4 else tmp5691)
tmp5689 = (tmp5533 if depth3 else tmp5690)
tmp5688 = (tmp5689 if depth2 else tmp5686)
tmp5684 = (tmp5685 if depth1 else tmp5688)
tmp5672 = (tmp5673 if s0 else tmp5684)
tmp5698 = (tmp4954 if depth6 else tmp5337)
tmp5697 = (tmp5698 if depth5 else tmp5548)
tmp5696 = (tmp5697 if depth4 else tmp5548)
tmp5695 = (tmp5696 if depth3 else tmp5548)
tmp5700 = (tmp5548 if depth4 else tmp5547)
tmp5699 = (tmp5548 if depth3 else tmp5700)
tmp5694 = (tmp5695 if depth2 else tmp5699)
tmp5701 = (tmp5548 if depth2 else tmp5699)
tmp5693 = (tmp5694 if depth1 else tmp5701)
tmp5706 = (tmp4955 if depth5 else tmp5346)
tmp5705 = (tmp5706 if depth4 else tmp5346)
tmp5704 = (tmp5705 if depth3 else tmp5346)
tmp5703 = (tmp5704 if depth2 else tmp5346)
tmp5711 = (tmp4955 if depth6 else tmp5352)
tmp5710 = (tmp5711 if depth5 else tmp5346)
tmp5709 = (tmp5710 if depth4 else tmp5346)
tmp5708 = (tmp5709 if depth3 else tmp5346)
tmp5707 = (tmp5708 if depth2 else tmp5346)
tmp5702 = (tmp5703 if depth1 else tmp5707)
tmp5692 = (tmp5693 if s0 else tmp5702)
tmp5671 = (tmp5672 if s1 else tmp5692)
tmp5636 = (tmp5637 if s2 else tmp5671)
tmp5561 = (tmp5562 if s3 else tmp5636)
tmp5354 = (tmp5355 if s4 else tmp5561)
tmp5721 = (tmp4992 if depth5 else tmp5364)
tmp5720 = (tmp5721 if depth4 else tmp5364)
tmp5719 = (tmp5720 if depth3 else tmp5364)
tmp5725 = (tmp4992 if depth6 else tmp5369)
tmp5724 = (tmp5725 if depth5 else tmp5364)
tmp5723 = (tmp5724 if depth4 else tmp5364)
tmp5722 = (tmp5723 if depth3 else tmp5364)
tmp5718 = (tmp5719 if depth2 else tmp5722)
tmp5730 = (tmp4992 if depth6 else tmp5375)
tmp5729 = (tmp5730 if depth5 else tmp5364)
tmp5728 = (tmp5729 if depth4 else tmp5364)
tmp5727 = (tmp5728 if depth3 else tmp5364)
tmp5726 = (tmp5727 if depth2 else tmp5364)
tmp5717 = (tmp5718 if depth1 else tmp5726)
tmp5735 = (tmp4956 if depth5 else tmp5381)
tmp5734 = (tmp5735 if depth4 else tmp5381)
tmp5733 = (tmp5734 if depth3 else tmp5381)
tmp5739 = (tmp4956 if depth6 else tmp5386)
tmp5738 = (tmp5739 if depth5 else tmp5381)
tmp5737 = (tmp5738 if depth4 else tmp5381)
tmp5736 = (tmp5737 if depth3 else tmp5381)
tmp5732 = (tmp5733 if depth2 else tmp5736)
tmp5744 = (tmp4956 if depth6 else tmp5392)
tmp5743 = (tmp5744 if depth5 else tmp5381)
tmp5742 = (tmp5743 if depth4 else tmp5381)
tmp5741 = (tmp5742 if depth3 else tmp5381)
tmp5748 = (tmp4956 if depth6 else tmp5397)
tmp5747 = (tmp5748 if depth5 else tmp5381)
tmp5746 = (tmp5747 if depth4 else tmp5381)
tmp5745 = (tmp5746 if depth3 else tmp5381)
tmp5740 = (tmp5741 if depth2 else tmp5745)
tmp5731 = (tmp5732 if depth1 else tmp5740)
tmp5716 = (tmp5717 if s0 else tmp5731)
tmp5752 = (tmp5734 if depth3 else tmp5746)
tmp5751 = (tmp5752 if depth2 else tmp5741)
tmp5750 = (tmp5751 if depth1 else tmp5732)
tmp5755 = (tmp5734 if depth3 else tmp5737)
tmp5754 = (tmp5755 if depth2 else tmp5733)
tmp5753 = (tmp5754 if depth1 else tmp5751)
tmp5749 = (tmp5750 if s0 else tmp5753)
tmp5715 = (tmp5716 if s1 else tmp5749)
tmp5762 = (tmp5049 if depth5 else tmp5412)
tmp5761 = (tmp5762 if depth4 else tmp5412)
tmp5765 = (tmp5049 if depth6 else tmp5416)
tmp5764 = (tmp5765 if depth5 else tmp5412)
tmp5763 = (tmp5764 if depth4 else tmp5412)
tmp5760 = (tmp5761 if depth3 else tmp5763)
tmp5766 = (tmp5761 if depth3 else tmp5412)
tmp5759 = (tmp5760 if depth2 else tmp5766)
tmp5771 = (tmp5049 if depth6 else tmp5423)
tmp5770 = (tmp5771 if depth5 else tmp5412)
tmp5769 = (tmp5770 if depth4 else tmp5412)
tmp5768 = (tmp5761 if depth3 else tmp5769)
tmp5767 = (tmp5768 if depth2 else tmp5766)
tmp5758 = (tmp5759 if depth1 else tmp5767)
tmp5775 = (tmp5050 if depth5 else tmp5428)
tmp5774 = (tmp5775 if depth4 else tmp5428)
tmp5776 = (tmp5774 if depth3 else tmp5428)
tmp5773 = (tmp5774 if depth2 else tmp5776)
tmp5781 = (tmp5050 if depth6 else tmp5435)
tmp5780 = (tmp5781 if depth5 else tmp5428)
tmp5779 = (tmp5780 if depth4 else tmp5428)
tmp5778 = (tmp5774 if depth3 else tmp5779)
tmp5777 = (tmp5778 if depth2 else tmp5776)
tmp5772 = (tmp5773 if depth1 else tmp5777)
tmp5757 = (tmp5758 if s0 else tmp5772)
tmp5787 = (tmp5088 if depth5 else tmp5442)
tmp5789 = (tmp5088 if depth6 else tmp5445)
tmp5788 = (tmp5789 if depth5 else tmp5442)
tmp5786 = (tmp5787 if depth4 else tmp5788)
tmp5790 = (tmp5787 if depth4 else tmp5442)
tmp5785 = (tmp5786 if depth3 else tmp5790)
tmp5792 = (tmp5788 if depth4 else tmp5442)
tmp5791 = (tmp5790 if depth3 else tmp5792)
tmp5784 = (tmp5785 if depth2 else tmp5791)
tmp5793 = (tmp5790 if depth2 else tmp5791)
tmp5783 = (tmp5784 if depth1 else tmp5793)
tmp5797 = (tmp4852 if depth5 else tmp5454)
tmp5798 = (tmp5797 if depth4 else tmp5454)
tmp5796 = (tmp5797 if depth3 else tmp5798)
tmp5795 = (tmp5796 if depth2 else tmp5798)
tmp5803 = (tmp4852 if depth6 else tmp5461)
tmp5802 = (tmp5803 if depth5 else tmp5454)
tmp5801 = (tmp5797 if depth4 else tmp5802)
tmp5800 = (tmp5801 if depth3 else tmp5798)
tmp5799 = (tmp5800 if depth2 else tmp5798)
tmp5794 = (tmp5795 if depth1 else tmp5799)
tmp5782 = (tmp5783 if s0 else tmp5794)
tmp5756 = (tmp5757 if s1 else tmp5782)
tmp5714 = (tmp5715 if s2 else tmp5756)
tmp5810 = (tmp4849 if depth5 else tmp5469)
tmp5811 = (tmp5810 if depth4 else tmp5469)
tmp5809 = (tmp5810 if depth3 else tmp5811)
tmp5815 = (tmp4849 if depth6 else tmp5475)
tmp5814 = (tmp5815 if depth5 else tmp5469)
tmp5813 = (tmp5810 if depth4 else tmp5814)
tmp5812 = (tmp5813 if depth3 else tmp5811)
tmp5808 = (tmp5809 if depth2 else tmp5812)
tmp5820 = (tmp4849 if depth6 else tmp5481)
tmp5819 = (tmp5820 if depth5 else tmp5469)
tmp5818 = (tmp5810 if depth4 else tmp5819)
tmp5817 = (tmp5818 if depth3 else tmp5811)
tmp5816 = (tmp5817 if depth2 else tmp5811)
tmp5807 = (tmp5808 if depth1 else tmp5816)
tmp5824 = (tmp4850 if depth5 else tmp5486)
tmp5825 = (tmp5824 if depth4 else tmp5486)
tmp5823 = (tmp5824 if depth3 else tmp5825)
tmp5829 = (tmp4850 if depth6 else tmp5492)
tmp5828 = (tmp5829 if depth5 else tmp5486)
tmp5827 = (tmp5824 if depth4 else tmp5828)
tmp5826 = (tmp5827 if depth3 else tmp5825)
tmp5822 = (tmp5823 if depth2 else tmp5826)
tmp5834 = (tmp4850 if depth6 else tmp5498)
tmp5833 = (tmp5834 if depth5 else tmp5486)
tmp5832 = (tmp5824 if depth4 else tmp5833)
tmp5831 = (tmp5832 if depth3 else tmp5825)
tmp5838 = (tmp4850 if depth6 else tmp5503)
tmp5837 = (tmp5838 if depth5 else tmp5486)
tmp5836 = (tmp5824 if depth4 else tmp5837)
tmp5835 = (tmp5836 if depth3 else tmp5825)
tmp5830 = (tmp5831 if depth2 else tmp5835)
tmp5821 = (tmp5822 if depth1 else tmp5830)
tmp5806 = (tmp5807 if s0 else tmp5821)
tmp5842 = (tmp5824 if depth3 else tmp5836)
tmp5841 = (tmp5842 if depth2 else tmp5831)
tmp5840 = (tmp5841 if depth1 else tmp5822)
tmp5845 = (tmp5824 if depth3 else tmp5827)
tmp5844 = (tmp5845 if depth2 else tmp5823)
tmp5843 = (tmp5844 if depth1 else tmp5841)
tmp5839 = (tmp5840 if s0 else tmp5843)
tmp5805 = (tmp5806 if s1 else tmp5839)
tmp5851 = (tmp4912 if depth5 else tmp5517)
tmp5854 = (tmp4912 if depth6 else tmp5521)
tmp5853 = (tmp5854 if depth5 else tmp5517)
tmp5852 = (tmp5851 if depth4 else tmp5853)
tmp5850 = (tmp5851 if depth3 else tmp5852)
tmp5856 = (tmp5851 if depth4 else tmp5517)
tmp5855 = (tmp5851 if depth3 else tmp5856)
tmp5849 = (tmp5850 if depth2 else tmp5855)
tmp5861 = (tmp4912 if depth6 else tmp5529)
tmp5860 = (tmp5861 if depth5 else tmp5517)
tmp5859 = (tmp5851 if depth4 else tmp5860)
tmp5858 = (tmp5851 if depth3 else tmp5859)
tmp5857 = (tmp5858 if depth2 else tmp5855)
tmp5848 = (tmp5849 if depth1 else tmp5857)
tmp5864 = (tmp4913 if depth5 else tmp5533)
tmp5866 = (tmp5864 if depth4 else tmp5533)
tmp5865 = (tmp5864 if depth3 else tmp5866)
tmp5863 = (tmp5864 if depth2 else tmp5865)
tmp5871 = (tmp4913 if depth6 else tmp5541)
tmp5870 = (tmp5871 if depth5 else tmp5533)
tmp5869 = (tmp5864 if depth4 else tmp5870)
tmp5868 = (tmp5864 if depth3 else tmp5869)
tmp5867 = (tmp5868 if depth2 else tmp5865)
tmp5862 = (tmp5863 if depth1 else tmp5867)
tmp5847 = (tmp5848 if s0 else tmp5862)
tmp5877 = (tmp4954 if depth5 else tmp5698)
tmp5878 = (tmp4954 if depth5 else tmp5548)
tmp5876 = (tmp5877 if depth4 else tmp5878)
tmp5875 = (tmp5876 if depth3 else tmp5878)
tmp5880 = (tmp5878 if depth4 else tmp5697)
tmp5879 = (tmp5878 if depth3 else tmp5880)
tmp5874 = (tmp5875 if depth2 else tmp5879)
tmp5881 = (tmp5878 if depth2 else tmp5879)
tmp5873 = (tmp5874 if depth1 else tmp5881)
tmp5885 = (tmp4955 if depth4 else tmp5706)
tmp5884 = (tmp5885 if depth3 else tmp5706)
tmp5883 = (tmp5884 if depth2 else tmp5706)
tmp5889 = (tmp4955 if depth5 else tmp5711)
tmp5888 = (tmp5889 if depth4 else tmp5706)
tmp5887 = (tmp5888 if depth3 else tmp5706)
tmp5886 = (tmp5887 if depth2 else tmp5706)
tmp5882 = (tmp5883 if depth1 else tmp5886)
tmp5872 = (tmp5873 if s0 else tmp5882)
tmp5846 = (tmp5847 if s1 else tmp5872)
tmp5804 = (tmp5805 if s2 else tmp5846)
tmp5713 = (tmp5714 if s3 else tmp5804)
tmp5897 = (tmp4992 if depth4 else tmp5721)
tmp5896 = (tmp5897 if depth3 else tmp5721)
tmp5900 = (tmp4992 if depth5 else tmp5725)
tmp5899 = (tmp5900 if depth4 else tmp5721)
tmp5898 = (tmp5899 if depth3 else tmp5721)
tmp5895 = (tmp5896 if depth2 else tmp5898)
tmp5904 = (tmp4992 if depth5 else tmp5730)
tmp5903 = (tmp5904 if depth4 else tmp5721)
tmp5902 = (tmp5903 if depth3 else tmp5721)
tmp5901 = (tmp5902 if depth2 else tmp5721)
tmp5894 = (tmp5895 if depth1 else tmp5901)
tmp5908 = (tmp4956 if depth4 else tmp5735)
tmp5907 = (tmp5908 if depth3 else tmp5735)
tmp5911 = (tmp4956 if depth5 else tmp5739)
tmp5910 = (tmp5911 if depth4 else tmp5735)
tmp5909 = (tmp5910 if depth3 else tmp5735)
tmp5906 = (tmp5907 if depth2 else tmp5909)
tmp5915 = (tmp4956 if depth5 else tmp5744)
tmp5914 = (tmp5915 if depth4 else tmp5735)
tmp5913 = (tmp5914 if depth3 else tmp5735)
tmp5918 = (tmp4956 if depth5 else tmp5748)
tmp5917 = (tmp5918 if depth4 else tmp5735)
tmp5916 = (tmp5917 if depth3 else tmp5735)
tmp5912 = (tmp5913 if depth2 else tmp5916)
tmp5905 = (tmp5906 if depth1 else tmp5912)
tmp5893 = (tmp5894 if s0 else tmp5905)
tmp5922 = (tmp5908 if depth3 else tmp5917)
tmp5921 = (tmp5922 if depth2 else tmp5913)
tmp5920 = (tmp5921 if depth1 else tmp5906)
tmp5925 = (tmp5908 if depth3 else tmp5910)
tmp5924 = (tmp5925 if depth2 else tmp5907)
tmp5923 = (tmp5924 if depth1 else tmp5921)
tmp5919 = (tmp5920 if s0 else tmp5923)
tmp5892 = (tmp5893 if s1 else tmp5919)
tmp5931 = (tmp5049 if depth4 else tmp5762)
tmp5933 = (tmp5049 if depth5 else tmp5765)
tmp5932 = (tmp5933 if depth4 else tmp5762)
tmp5930 = (tmp5931 if depth3 else tmp5932)
tmp5934 = (tmp5931 if depth3 else tmp5762)
tmp5929 = (tmp5930 if depth2 else tmp5934)
tmp5938 = (tmp5049 if depth5 else tmp5771)
tmp5937 = (tmp5938 if depth4 else tmp5762)
tmp5936 = (tmp5931 if depth3 else tmp5937)
tmp5935 = (tmp5936 if depth2 else tmp5934)
tmp5928 = (tmp5929 if depth1 else tmp5935)
tmp5941 = (tmp5050 if depth4 else tmp5775)
tmp5942 = (tmp5941 if depth3 else tmp5775)
tmp5940 = (tmp5941 if depth2 else tmp5942)
tmp5946 = (tmp5050 if depth5 else tmp5781)
tmp5945 = (tmp5946 if depth4 else tmp5775)
tmp5944 = (tmp5941 if depth3 else tmp5945)
tmp5943 = (tmp5944 if depth2 else tmp5942)
tmp5939 = (tmp5940 if depth1 else tmp5943)
tmp5927 = (tmp5928 if s0 else tmp5939)
tmp5952 = (tmp5088 if depth5 else tmp5789)
tmp5951 = (tmp5088 if depth4 else tmp5952)
tmp5953 = (tmp5088 if depth4 else tmp5787)
tmp5950 = (tmp5951 if depth3 else tmp5953)
tmp5955 = (tmp5952 if depth4 else tmp5787)
tmp5954 = (tmp5953 if depth3 else tmp5955)
tmp5949 = (tmp5950 if depth2 else tmp5954)
tmp5956 = (tmp5953 if depth2 else tmp5954)
tmp5948 = (tmp5949 if depth1 else tmp5956)
tmp5960 = (tmp4852 if depth4 else tmp5797)
tmp5959 = (tmp4852 if depth3 else tmp5960)
tmp5958 = (tmp5959 if depth2 else tmp5960)
tmp5964 = (tmp4852 if depth5 else tmp5803)
tmp5963 = (tmp4852 if depth4 else tmp5964)
tmp5962 = (tmp5963 if depth3 else tmp5960)
tmp5961 = (tmp5962 if depth2 else tmp5960)
tmp5957 = (tmp5958 if depth1 else tmp5961)
tmp5947 = (tmp5948 if s0 else tmp5957)
tmp5926 = (tmp5927 if s1 else tmp5947)
tmp5891 = (tmp5892 if s2 else tmp5926)
tmp5971 = (tmp4849 if depth4 else tmp5810)
tmp5970 = (tmp4849 if depth3 else tmp5971)
tmp5974 = (tmp4849 if depth5 else tmp5815)
tmp5973 = (tmp4849 if depth4 else tmp5974)
tmp5972 = (tmp5973 if depth3 else tmp5971)
tmp5969 = (tmp5970 if depth2 else tmp5972)
tmp5978 = (tmp4849 if depth5 else tmp5820)
tmp5977 = (tmp4849 if depth4 else tmp5978)
tmp5976 = (tmp5977 if depth3 else tmp5971)
tmp5975 = (tmp5976 if depth2 else tmp5971)
tmp5968 = (tmp5969 if depth1 else tmp5975)
tmp5982 = (tmp4850 if depth4 else tmp5824)
tmp5981 = (tmp4850 if depth3 else tmp5982)
tmp5985 = (tmp4850 if depth5 else tmp5829)
tmp5984 = (tmp4850 if depth4 else tmp5985)
tmp5983 = (tmp5984 if depth3 else tmp5982)
tmp5980 = (tmp5981 if depth2 else tmp5983)
tmp5989 = (tmp4850 if depth5 else tmp5834)
tmp5988 = (tmp4850 if depth4 else tmp5989)
tmp5987 = (tmp5988 if depth3 else tmp5982)
tmp5992 = (tmp4850 if depth5 else tmp5838)
tmp5991 = (tmp4850 if depth4 else tmp5992)
tmp5990 = (tmp5991 if depth3 else tmp5982)
tmp5986 = (tmp5987 if depth2 else tmp5990)
tmp5979 = (tmp5980 if depth1 else tmp5986)
tmp5967 = (tmp5968 if s0 else tmp5979)
tmp5996 = (tmp4850 if depth3 else tmp5991)
tmp5995 = (tmp5996 if depth2 else tmp5987)
tmp5994 = (tmp5995 if depth1 else tmp5980)
tmp5999 = (tmp4850 if depth3 else tmp5984)
tmp5998 = (tmp5999 if depth2 else tmp5981)
tmp5997 = (tmp5998 if depth1 else tmp5995)
tmp5993 = (tmp5994 if s0 else tmp5997)
tmp5966 = (tmp5967 if s1 else tmp5993)
tmp6004 = (tmp4850 if depth3 else tmp5988)
tmp6003 = (tmp6004 if depth2 else tmp5996)
tmp6002 = (tmp6003 if depth1 else tmp5998)
tmp6006 = (tmp4850 if depth2 else tmp5999)
tmp6005 = (tmp6006 if depth1 else tmp6003)
tmp6001 = (tmp6002 if s0 else tmp6005)
tmp6009 = (tmp4850 if depth2 else tmp6004)
tmp6008 = (tmp6009 if depth1 else tmp6006)
tmp6010 = (tmp4850 if depth1 else tmp6009)
tmp6007 = (tmp6008 if s0 else tmp6010)
tmp6000 = (tmp6001 if s1 else tmp6007)
tmp5965 = (tmp5966 if s2 else tmp6000)
tmp5890 = (tmp5891 if s3 else tmp5965)
tmp5712 = (tmp5713 if s4 else tmp5890)
tmp5353 = (1 - (tmp5354 if s5 else tmp5712))
tmp4789 = (tmp4790 if s6 else tmp5353)
tmp4765 = (tmp4766 if s7 else tmp4789)
s3n = tmp4765
tmp6016 = (1 - (1 if oxygen_low else 0))
tmp6015 = (1 if oxygen_full else tmp6016)
tmp6020 = (1 if oxygen_full else 0)
tmp6019 = (1 if k2 else tmp6020)
tmp6018 = (tmp6019 if k1 else tmp6020)
tmp6017 = (tmp6018 if s0 else tmp6019)
tmp6014 = (tmp6015 if s1 else tmp6017)
tmp6024 = (1 if k1 else tmp6019)
tmp6023 = (tmp6024 if s0 else 1)
tmp6027 = (tmp6020 if k2 else 1)
tmp6026 = (tmp6027 if k1 else 1)
tmp6025 = (tmp6026 if s0 else tmp6027)
tmp6022 = (tmp6023 if s1 else tmp6025)
tmp6030 = (tmp6020 if k1 else tmp6027)
tmp6029 = (tmp6030 if s0 else tmp6020)
tmp6028 = (tmp6029 if s1 else tmp6017)
tmp6021 = (tmp6022 if s2 else tmp6028)
tmp6013 = (tmp6014 if s4 else tmp6021)
tmp6012 = (tmp6013 if s6 else tmp6021)
tmp6036 = (tmp6023 if s1 else 1)
tmp6048 = (1 if action1_1 else 0)
tmp6049 = (1 - (1 if action1_1 else 0))
tmp6047 = (tmp6048 if action2_1 else tmp6049)
tmp6050 = (1 if action2_1 else tmp6049)
tmp6046 = (tmp6047 if action3_1 else tmp6050)
tmp6045 = (1 if action4_1 else tmp6046)
tmp6044 = (tmp6045 if oxygen_low else 1)
tmp6043 = (1 if oxygen_full else tmp6044)
tmp6042 = (tmp6015 if k2 else tmp6043)
tmp6056 = (1 if action2_1 else tmp6048)
tmp6055 = (1 if action3_1 else tmp6056)
tmp6054 = (tmp6055 if action4_1 else 0)
tmp6053 = (tmp6054 if oxygen_low else 1)
tmp6052 = (1 if oxygen_full else tmp6053)
tmp6051 = (tmp6015 if k2 else tmp6052)
tmp6041 = (tmp6042 if depth7 else tmp6051)
tmp6040 = (tmp6041 if depth6 else tmp6051)
tmp6057 = (tmp6040 if depth5 else tmp6051)
tmp6039 = (tmp6040 if depth4 else tmp6057)
tmp6064 = (tmp6042 if k1 else tmp6051)
tmp6063 = (tmp6064 if depth7 else tmp6051)
tmp6062 = (tmp6063 if depth6 else tmp6051)
tmp6061 = (tmp6040 if depth5 else tmp6062)
tmp6060 = (tmp6061 if depth4 else tmp6057)
tmp6059 = (tmp6039 if depth3 else tmp6060)
tmp6058 = (tmp6039 if depth2 else tmp6059)
tmp6038 = (tmp6039 if depth1 else tmp6058)
tmp6037 = (1 if s1 else tmp6038)
tmp6035 = (tmp6036 if s2 else tmp6037)
tmp6076 = (1 - (1 if action4_1 else tmp6046))
tmp6075 = (1 if oxygen_full else tmp6076)
tmp6074 = (tmp6075 if k2 else tmp6020)
tmp6078 = (1 if oxygen_full else tmp6045)
tmp6077 = (tmp6020 if k2 else tmp6078)
tmp6073 = (tmp6074 if k1 else tmp6077)
tmp6082 = (1 - (tmp6055 if action4_1 else 0))
tmp6081 = (1 if oxygen_full else tmp6082)
tmp6080 = (tmp6081 if k2 else tmp6020)
tmp6084 = (1 if oxygen_full else tmp6054)
tmp6083 = (tmp6020 if k2 else tmp6084)
tmp6079 = (tmp6080 if k1 else tmp6083)
tmp6072 = (tmp6073 if depth7 else tmp6079)
tmp6071 = (tmp6072 if depth6 else tmp6079)
tmp6088 = (tmp6074 if k1 else tmp6083)
tmp6087 = (tmp6088 if depth7 else tmp6079)
tmp6086 = (tmp6087 if depth6 else tmp6079)
tmp6085 = (tmp6071 if depth5 else tmp6086)
tmp6070 = (tmp6071 if depth4 else tmp6085)
tmp6090 = (tmp6071 if depth5 else tmp6079)
tmp6089 = (tmp6071 if depth4 else tmp6090)
tmp6069 = (tmp6070 if depth3 else tmp6089)
tmp6091 = (tmp6069 if depth2 else tmp6089)
tmp6068 = (tmp6069 if depth1 else tmp6091)
tmp6095 = (tmp6074 if depth7 else tmp6080)
tmp6094 = (tmp6095 if depth6 else tmp6080)
tmp6097 = (tmp6094 if depth5 else tmp6080)
tmp6096 = (tmp6094 if depth4 else tmp6097)
tmp6093 = (tmp6094 if depth3 else tmp6096)
tmp6104 = (tmp6074 if k1 else tmp6080)
tmp6103 = (tmp6104 if depth7 else tmp6080)
tmp6102 = (tmp6103 if depth6 else tmp6080)
tmp6101 = (tmp6094 if depth5 else tmp6102)
tmp6100 = (tmp6094 if depth4 else tmp6101)
tmp6099 = (tmp6100 if depth3 else tmp6096)
tmp6098 = (tmp6093 if depth2 else tmp6099)
tmp6092 = (tmp6093 if depth1 else tmp6098)
tmp6067 = (tmp6068 if s0 else tmp6092)
tmp6111 = (1 if k2 else tmp6075)
tmp6110 = (tmp6111 if k1 else tmp6074)
tmp6113 = (1 if k2 else tmp6081)
tmp6112 = (tmp6113 if k1 else tmp6080)
tmp6109 = (tmp6110 if depth7 else tmp6112)
tmp6108 = (tmp6109 if depth6 else tmp6112)
tmp6115 = (tmp6108 if depth5 else tmp6112)
tmp6114 = (tmp6108 if depth4 else tmp6115)
tmp6107 = (tmp6108 if depth3 else tmp6114)
tmp6122 = (tmp6113 if k1 else tmp6074)
tmp6121 = (tmp6122 if depth7 else tmp6112)
tmp6120 = (tmp6121 if depth6 else tmp6112)
tmp6119 = (tmp6108 if depth5 else tmp6120)
tmp6118 = (tmp6108 if depth4 else tmp6119)
tmp6117 = (tmp6118 if depth3 else tmp6114)
tmp6116 = (tmp6107 if depth2 else tmp6117)
tmp6106 = (tmp6107 if depth1 else tmp6116)
tmp6126 = (tmp6111 if depth7 else tmp6113)
tmp6125 = (tmp6126 if depth6 else tmp6113)
tmp6128 = (tmp6125 if depth5 else tmp6113)
tmp6127 = (tmp6125 if depth4 else tmp6128)
tmp6124 = (tmp6125 if depth3 else tmp6127)
tmp6135 = (tmp6111 if k1 else tmp6113)
tmp6134 = (tmp6135 if depth7 else tmp6113)
tmp6133 = (tmp6134 if depth6 else tmp6113)
tmp6132 = (tmp6125 if depth5 else tmp6133)
tmp6131 = (tmp6125 if depth4 else tmp6132)
tmp6130 = (tmp6131 if depth3 else tmp6127)
tmp6129 = (tmp6124 if depth2 else tmp6130)
tmp6123 = (tmp6124 if depth1 else tmp6129)
tmp6105 = (tmp6106 if s0 else tmp6123)
tmp6066 = (tmp6067 if s1 else tmp6105)
tmp6143 = (tmp6078 if k2 else 1)
tmp6142 = (tmp6143 if k1 else tmp6111)
tmp6145 = (tmp6084 if k2 else 1)
tmp6144 = (tmp6145 if k1 else tmp6113)
tmp6141 = (tmp6142 if depth7 else tmp6144)
tmp6140 = (tmp6141 if depth6 else tmp6144)
tmp6150 = (tmp6143 if k1 else tmp6113)
tmp6149 = (tmp6150 if depth7 else tmp6144)
tmp6148 = (tmp6149 if depth6 else tmp6144)
tmp6147 = (tmp6140 if depth5 else tmp6148)
tmp6146 = (tmp6140 if depth4 else tmp6147)
tmp6139 = (tmp6140 if depth3 else tmp6146)
tmp6154 = (tmp6140 if depth5 else tmp6144)
tmp6153 = (tmp6140 if depth4 else tmp6154)
tmp6152 = (tmp6140 if depth3 else tmp6153)
tmp6151 = (tmp6139 if depth2 else tmp6152)
tmp6138 = (tmp6139 if depth1 else tmp6151)
tmp6157 = (tmp6143 if depth7 else tmp6145)
tmp6156 = (tmp6157 if depth6 else tmp6145)
tmp6164 = (tmp6143 if k1 else tmp6145)
tmp6163 = (tmp6164 if depth7 else tmp6145)
tmp6162 = (tmp6163 if depth6 else tmp6145)
tmp6161 = (tmp6156 if depth5 else tmp6162)
tmp6160 = (tmp6156 if depth4 else tmp6161)
tmp6159 = (tmp6156 if depth3 else tmp6160)
tmp6158 = (tmp6156 if depth2 else tmp6159)
tmp6155 = (tmp6156 if depth1 else tmp6158)
tmp6137 = (tmp6138 if s0 else tmp6155)
tmp6169 = (tmp6077 if k1 else tmp6143)
tmp6170 = (tmp6083 if k1 else tmp6145)
tmp6168 = (tmp6169 if depth7 else tmp6170)
tmp6167 = (tmp6168 if depth6 else tmp6170)
tmp6177 = (tmp6083 if k1 else tmp6143)
tmp6176 = (tmp6177 if depth7 else tmp6170)
tmp6175 = (tmp6176 if depth6 else tmp6170)
tmp6174 = (tmp6167 if depth5 else tmp6175)
tmp6173 = (tmp6167 if depth4 else tmp6174)
tmp6172 = (tmp6167 if depth3 else tmp6173)
tmp6171 = (tmp6167 if depth2 else tmp6172)
tmp6166 = (tmp6167 if depth1 else tmp6171)
tmp6180 = (tmp6077 if depth7 else tmp6083)
tmp6179 = (tmp6180 if depth6 else tmp6083)
tmp6187 = (tmp6077 if k1 else tmp6083)
tmp6186 = (tmp6187 if depth7 else tmp6083)
tmp6185 = (tmp6186 if depth6 else tmp6083)
tmp6184 = (tmp6179 if depth5 else tmp6185)
tmp6183 = (tmp6179 if depth4 else tmp6184)
tmp6182 = (tmp6179 if depth3 else tmp6183)
tmp6181 = (tmp6179 if depth2 else tmp6182)
tmp6178 = (tmp6179 if depth1 else tmp6181)
tmp6165 = (tmp6166 if s0 else tmp6178)
tmp6136 = (tmp6137 if s1 else tmp6165)
tmp6065 = (tmp6066 if s2 else tmp6136)
tmp6034 = (tmp6035 if s3 else tmp6065)
tmp6033 = (tmp6021 if s4 else tmp6034)
tmp6197 = (tmp6072 if depth6 else tmp6087)
tmp6196 = (tmp6197 if depth5 else tmp6071)
tmp6195 = (tmp6196 if depth4 else tmp6071)
tmp6194 = (tmp6195 if depth3 else tmp6071)
tmp6198 = (tmp6194 if depth2 else tmp6071)
tmp6193 = (tmp6194 if depth1 else tmp6198)
tmp6202 = (tmp6095 if depth5 else tmp6094)
tmp6201 = (tmp6202 if depth4 else tmp6094)
tmp6200 = (tmp6201 if depth3 else tmp6094)
tmp6207 = (tmp6095 if depth6 else tmp6103)
tmp6206 = (tmp6207 if depth5 else tmp6094)
tmp6205 = (tmp6206 if depth4 else tmp6094)
tmp6204 = (tmp6205 if depth3 else tmp6094)
tmp6203 = (tmp6200 if depth2 else tmp6204)
tmp6199 = (tmp6200 if depth1 else tmp6203)
tmp6192 = (tmp6193 if s0 else tmp6199)
tmp6212 = (tmp6109 if depth5 else tmp6108)
tmp6211 = (tmp6212 if depth4 else tmp6108)
tmp6210 = (tmp6211 if depth3 else tmp6108)
tmp6217 = (tmp6109 if depth6 else tmp6121)
tmp6216 = (tmp6217 if depth5 else tmp6108)
tmp6215 = (tmp6216 if depth4 else tmp6108)
tmp6214 = (tmp6215 if depth3 else tmp6108)
tmp6213 = (tmp6210 if depth2 else tmp6214)
tmp6209 = (tmp6210 if depth1 else tmp6213)
tmp6221 = (tmp6126 if depth5 else tmp6125)
tmp6220 = (tmp6221 if depth4 else tmp6125)
tmp6219 = (tmp6220 if depth3 else tmp6125)
tmp6226 = (tmp6126 if depth6 else tmp6134)
tmp6225 = (tmp6226 if depth5 else tmp6125)
tmp6224 = (tmp6225 if depth4 else tmp6125)
tmp6223 = (tmp6224 if depth3 else tmp6125)
tmp6222 = (tmp6219 if depth2 else tmp6223)
tmp6218 = (tmp6219 if depth1 else tmp6222)
tmp6208 = (tmp6209 if s0 else tmp6218)
tmp6191 = (tmp6192 if s1 else tmp6208)
tmp6232 = (tmp6141 if depth5 else tmp6140)
tmp6231 = (tmp6232 if depth4 else tmp6140)
tmp6235 = (tmp6141 if depth6 else tmp6149)
tmp6234 = (tmp6235 if depth5 else tmp6140)
tmp6233 = (tmp6234 if depth4 else tmp6140)
tmp6230 = (tmp6231 if depth3 else tmp6233)
tmp6237 = (tmp6231 if depth3 else tmp6140)
tmp6236 = (tmp6230 if depth2 else tmp6237)
tmp6229 = (tmp6230 if depth1 else tmp6236)
tmp6240 = (tmp6157 if depth5 else tmp6156)
tmp6239 = (tmp6240 if depth4 else tmp6156)
tmp6245 = (tmp6157 if depth6 else tmp6163)
tmp6244 = (tmp6245 if depth5 else tmp6156)
tmp6243 = (tmp6244 if depth4 else tmp6156)
tmp6242 = (tmp6239 if depth3 else tmp6243)
tmp6241 = (tmp6239 if depth2 else tmp6242)
tmp6238 = (tmp6239 if depth1 else tmp6241)
tmp6228 = (tmp6229 if s0 else tmp6238)
tmp6249 = (tmp6168 if depth5 else tmp6167)
tmp6248 = (tmp6249 if depth4 else tmp6167)
tmp6254 = (tmp6168 if depth6 else tmp6176)
tmp6253 = (tmp6254 if depth5 else tmp6167)
tmp6252 = (tmp6253 if depth4 else tmp6167)
tmp6251 = (tmp6248 if depth3 else tmp6252)
tmp6250 = (tmp6248 if depth2 else tmp6251)
tmp6247 = (tmp6248 if depth1 else tmp6250)
tmp6257 = (tmp6180 if depth5 else tmp6179)
tmp6256 = (tmp6257 if depth4 else tmp6179)
tmp6262 = (tmp6180 if depth6 else tmp6186)
tmp6261 = (tmp6262 if depth5 else tmp6179)
tmp6260 = (tmp6261 if depth4 else tmp6179)
tmp6259 = (tmp6256 if depth3 else tmp6260)
tmp6258 = (tmp6256 if depth2 else tmp6259)
tmp6255 = (tmp6256 if depth1 else tmp6258)
tmp6246 = (tmp6247 if s0 else tmp6255)
tmp6227 = (tmp6228 if s1 else tmp6246)
tmp6190 = (tmp6191 if s2 else tmp6227)
tmp6269 = (tmp6072 if depth5 else tmp6071)
tmp6268 = (tmp6269 if depth4 else tmp6196)
tmp6270 = (tmp6269 if depth4 else tmp6071)
tmp6267 = (tmp6268 if depth3 else tmp6270)
tmp6271 = (tmp6267 if depth2 else tmp6270)
tmp6266 = (tmp6267 if depth1 else tmp6271)
tmp6273 = (tmp6202 if depth3 else tmp6201)
tmp6276 = (tmp6202 if depth4 else tmp6206)
tmp6275 = (tmp6276 if depth3 else tmp6201)
tmp6274 = (tmp6273 if depth2 else tmp6275)
tmp6272 = (tmp6273 if depth1 else tmp6274)
tmp6265 = (tmp6266 if s0 else tmp6272)
tmp6279 = (tmp6212 if depth3 else tmp6211)
tmp6282 = (tmp6212 if depth4 else tmp6216)
tmp6281 = (tmp6282 if depth3 else tmp6211)
tmp6280 = (tmp6279 if depth2 else tmp6281)
tmp6278 = (tmp6279 if depth1 else tmp6280)
tmp6284 = (tmp6221 if depth3 else tmp6220)
tmp6287 = (tmp6221 if depth4 else tmp6225)
tmp6286 = (tmp6287 if depth3 else tmp6220)
tmp6285 = (tmp6284 if depth2 else tmp6286)
tmp6283 = (tmp6284 if depth1 else tmp6285)
tmp6277 = (tmp6278 if s0 else tmp6283)
tmp6264 = (tmp6265 if s1 else tmp6277)
tmp6292 = (tmp6232 if depth4 else tmp6234)
tmp6291 = (tmp6232 if depth3 else tmp6292)
tmp6294 = (tmp6232 if depth3 else tmp6231)
tmp6293 = (tmp6291 if depth2 else tmp6294)
tmp6290 = (tmp6291 if depth1 else tmp6293)
tmp6298 = (tmp6240 if depth4 else tmp6244)
tmp6297 = (tmp6240 if depth3 else tmp6298)
tmp6296 = (tmp6240 if depth2 else tmp6297)
tmp6295 = (tmp6240 if depth1 else tmp6296)
tmp6289 = (tmp6290 if s0 else tmp6295)
tmp6303 = (tmp6249 if depth4 else tmp6253)
tmp6302 = (tmp6249 if depth3 else tmp6303)
tmp6301 = (tmp6249 if depth2 else tmp6302)
tmp6300 = (tmp6249 if depth1 else tmp6301)
tmp6307 = (tmp6257 if depth4 else tmp6261)
tmp6306 = (tmp6257 if depth3 else tmp6307)
tmp6305 = (tmp6257 if depth2 else tmp6306)
tmp6304 = (tmp6257 if depth1 else tmp6305)
tmp6299 = (tmp6300 if s0 else tmp6304)
tmp6288 = (tmp6289 if s1 else tmp6299)
tmp6263 = (tmp6264 if s2 else tmp6288)
tmp6189 = (tmp6190 if s3 else tmp6263)
tmp6315 = (tmp6072 if depth5 else tmp6197)
tmp6314 = (tmp6315 if depth4 else tmp6269)
tmp6313 = (tmp6314 if depth3 else tmp6269)
tmp6316 = (tmp6313 if depth2 else tmp6269)
tmp6312 = (tmp6313 if depth1 else tmp6316)
tmp6319 = (tmp6095 if depth4 else tmp6202)
tmp6318 = (tmp6319 if depth3 else tmp6202)
tmp6323 = (tmp6095 if depth5 else tmp6207)
tmp6322 = (tmp6323 if depth4 else tmp6202)
tmp6321 = (tmp6322 if depth3 else tmp6202)
tmp6320 = (tmp6318 if depth2 else tmp6321)
tmp6317 = (tmp6318 if depth1 else tmp6320)
tmp6311 = (tmp6312 if s0 else tmp6317)
tmp6327 = (tmp6109 if depth4 else tmp6212)
tmp6326 = (tmp6327 if depth3 else tmp6212)
tmp6331 = (tmp6109 if depth5 else tmp6217)
tmp6330 = (tmp6331 if depth4 else tmp6212)
tmp6329 = (tmp6330 if depth3 else tmp6212)
tmp6328 = (tmp6326 if depth2 else tmp6329)
tmp6325 = (tmp6326 if depth1 else tmp6328)
tmp6334 = (tmp6126 if depth4 else tmp6221)
tmp6333 = (tmp6334 if depth3 else tmp6221)
tmp6338 = (tmp6126 if depth5 else tmp6226)
tmp6337 = (tmp6338 if depth4 else tmp6221)
tmp6336 = (tmp6337 if depth3 else tmp6221)
tmp6335 = (tmp6333 if depth2 else tmp6336)
tmp6332 = (tmp6333 if depth1 else tmp6335)
tmp6324 = (tmp6325 if s0 else tmp6332)
tmp6310 = (tmp6311 if s1 else tmp6324)
tmp6343 = (tmp6141 if depth4 else tmp6232)
tmp6345 = (tmp6141 if depth5 else tmp6235)
tmp6344 = (tmp6345 if depth4 else tmp6232)
tmp6342 = (tmp6343 if depth3 else tmp6344)
tmp6347 = (tmp6343 if depth3 else tmp6232)
tmp6346 = (tmp6342 if depth2 else tmp6347)
tmp6341 = (tmp6342 if depth1 else tmp6346)
tmp6349 = (tmp6157 if depth4 else tmp6240)
tmp6353 = (tmp6157 if depth5 else tmp6245)
tmp6352 = (tmp6353 if depth4 else tmp6240)
tmp6351 = (tmp6349 if depth3 else tmp6352)
tmp6350 = (tmp6349 if depth2 else tmp6351)
tmp6348 = (tmp6349 if depth1 else tmp6350)
tmp6340 = (tmp6341 if s0 else tmp6348)
tmp6356 = (tmp6168 if depth4 else tmp6249)
tmp6360 = (tmp6168 if depth5 else tmp6254)
tmp6359 = (tmp6360 if depth4 else tmp6249)
tmp6358 = (tmp6356 if depth3 else tmp6359)
tmp6357 = (tmp6356 if depth2 else tmp6358)
tmp6355 = (tmp6356 if depth1 else tmp6357)
tmp6362 = (tmp6180 if depth4 else tmp6257)
tmp6366 = (tmp6180 if depth5 else tmp6262)
tmp6365 = (tmp6366 if depth4 else tmp6257)
tmp6364 = (tmp6362 if depth3 else tmp6365)
tmp6363 = (tmp6362 if depth2 else tmp6364)
tmp6361 = (tmp6362 if depth1 else tmp6363)
tmp6354 = (tmp6355 if s0 else tmp6361)
tmp6339 = (tmp6340 if s1 else tmp6354)
tmp6309 = (tmp6310 if s2 else tmp6339)
tmp6372 = (tmp6072 if depth4 else tmp6315)
tmp6373 = (tmp6072 if depth4 else tmp6269)
tmp6371 = (tmp6372 if depth3 else tmp6373)
tmp6374 = (tmp6371 if depth2 else tmp6373)
tmp6370 = (tmp6371 if depth1 else tmp6374)
tmp6376 = (tmp6095 if depth3 else tmp6319)
tmp6379 = (tmp6095 if depth4 else tmp6323)
tmp6378 = (tmp6379 if depth3 else tmp6319)
tmp6377 = (tmp6376 if depth2 else tmp6378)
tmp6375 = (tmp6376 if depth1 else tmp6377)
tmp6369 = (tmp6370 if s0 else tmp6375)
tmp6382 = (tmp6109 if depth3 else tmp6327)
tmp6385 = (tmp6109 if depth4 else tmp6331)
tmp6384 = (tmp6385 if depth3 else tmp6327)
tmp6383 = (tmp6382 if depth2 else tmp6384)
tmp6381 = (tmp6382 if depth1 else tmp6383)
tmp6387 = (tmp6126 if depth3 else tmp6334)
tmp6390 = (tmp6126 if depth4 else tmp6338)
tmp6389 = (tmp6390 if depth3 else tmp6334)
tmp6388 = (tmp6387 if depth2 else tmp6389)
tmp6386 = (tmp6387 if depth1 else tmp6388)
tmp6380 = (tmp6381 if s0 else tmp6386)
tmp6368 = (tmp6369 if s1 else tmp6380)
tmp6395 = (tmp6141 if depth4 else tmp6345)
tmp6394 = (tmp6141 if depth3 else tmp6395)
tmp6397 = (tmp6141 if depth3 else tmp6343)
tmp6396 = (tmp6394 if depth2 else tmp6397)
tmp6393 = (tmp6394 if depth1 else tmp6396)
tmp6401 = (tmp6157 if depth4 else tmp6353)
tmp6400 = (tmp6157 if depth3 else tmp6401)
tmp6399 = (tmp6157 if depth2 else tmp6400)
tmp6398 = (tmp6157 if depth1 else tmp6399)
tmp6392 = (tmp6393 if s0 else tmp6398)
tmp6406 = (tmp6168 if depth4 else tmp6360)
tmp6405 = (tmp6168 if depth3 else tmp6406)
tmp6404 = (tmp6168 if depth2 else tmp6405)
tmp6403 = (tmp6168 if depth1 else tmp6404)
tmp6410 = (tmp6180 if depth4 else tmp6366)
tmp6409 = (tmp6180 if depth3 else tmp6410)
tmp6408 = (tmp6180 if depth2 else tmp6409)
tmp6407 = (tmp6180 if depth1 else tmp6408)
tmp6402 = (tmp6403 if s0 else tmp6407)
tmp6391 = (tmp6392 if s1 else tmp6402)
tmp6367 = (tmp6368 if s2 else tmp6391)
tmp6308 = (tmp6309 if s3 else tmp6367)
tmp6188 = (tmp6189 if s4 else tmp6308)
tmp6032 = (tmp6033 if s5 else tmp6188)
tmp6422 = (tmp6073 if depth7 else tmp6088)
tmp6421 = (tmp6422 if depth6 else tmp6072)
tmp6420 = (tmp6421 if depth5 else tmp6072)
tmp6419 = (tmp6420 if depth4 else tmp6072)
tmp6418 = (tmp6419 if depth3 else tmp6072)
tmp6423 = (tmp6418 if depth2 else tmp6072)
tmp6417 = (tmp6418 if depth1 else tmp6423)
tmp6428 = (tmp6074 if depth6 else tmp6095)
tmp6427 = (tmp6428 if depth5 else tmp6095)
tmp6426 = (tmp6427 if depth4 else tmp6095)
tmp6425 = (tmp6426 if depth3 else tmp6095)
tmp6434 = (tmp6074 if depth7 else tmp6104)
tmp6433 = (tmp6434 if depth6 else tmp6095)
tmp6432 = (tmp6433 if depth5 else tmp6095)
tmp6431 = (tmp6432 if depth4 else tmp6095)
tmp6430 = (tmp6431 if depth3 else tmp6095)
tmp6429 = (tmp6425 if depth2 else tmp6430)
tmp6424 = (tmp6425 if depth1 else tmp6429)
tmp6416 = (tmp6417 if s0 else tmp6424)
tmp6440 = (tmp6110 if depth6 else tmp6109)
tmp6439 = (tmp6440 if depth5 else tmp6109)
tmp6438 = (tmp6439 if depth4 else tmp6109)
tmp6437 = (tmp6438 if depth3 else tmp6109)
tmp6446 = (tmp6110 if depth7 else tmp6122)
tmp6445 = (tmp6446 if depth6 else tmp6109)
tmp6444 = (tmp6445 if depth5 else tmp6109)
tmp6443 = (tmp6444 if depth4 else tmp6109)
tmp6442 = (tmp6443 if depth3 else tmp6109)
tmp6441 = (tmp6437 if depth2 else tmp6442)
tmp6436 = (tmp6437 if depth1 else tmp6441)
tmp6451 = (tmp6111 if depth6 else tmp6126)
tmp6450 = (tmp6451 if depth5 else tmp6126)
tmp6449 = (tmp6450 if depth4 else tmp6126)
tmp6448 = (tmp6449 if depth3 else tmp6126)
tmp6457 = (tmp6111 if depth7 else tmp6135)
tmp6456 = (tmp6457 if depth6 else tmp6126)
tmp6455 = (tmp6456 if depth5 else tmp6126)
tmp6454 = (tmp6455 if depth4 else tmp6126)
tmp6453 = (tmp6454 if depth3 else tmp6126)
tmp6452 = (tmp6448 if depth2 else tmp6453)
tmp6447 = (tmp6448 if depth1 else tmp6452)
tmp6435 = (tmp6436 if s0 else tmp6447)
tmp6415 = (tmp6416 if s1 else tmp6435)
tmp6464 = (tmp6142 if depth6 else tmp6141)
tmp6463 = (tmp6464 if depth5 else tmp6141)
tmp6462 = (tmp6463 if depth4 else tmp6141)
tmp6468 = (tmp6142 if depth7 else tmp6150)
tmp6467 = (tmp6468 if depth6 else tmp6141)
tmp6466 = (tmp6467 if depth5 else tmp6141)
tmp6465 = (tmp6466 if depth4 else tmp6141)
tmp6461 = (tmp6462 if depth3 else tmp6465)
tmp6470 = (tmp6462 if depth3 else tmp6141)
tmp6469 = (tmp6461 if depth2 else tmp6470)
tmp6460 = (tmp6461 if depth1 else tmp6469)
tmp6474 = (tmp6143 if depth6 else tmp6157)
tmp6473 = (tmp6474 if depth5 else tmp6157)
tmp6472 = (tmp6473 if depth4 else tmp6157)
tmp6480 = (tmp6143 if depth7 else tmp6164)
tmp6479 = (tmp6480 if depth6 else tmp6157)
tmp6478 = (tmp6479 if depth5 else tmp6157)
tmp6477 = (tmp6478 if depth4 else tmp6157)
tmp6476 = (tmp6472 if depth3 else tmp6477)
tmp6475 = (tmp6472 if depth2 else tmp6476)
tmp6471 = (tmp6472 if depth1 else tmp6475)
tmp6459 = (tmp6460 if s0 else tmp6471)
tmp6485 = (tmp6169 if depth6 else tmp6168)
tmp6484 = (tmp6485 if depth5 else tmp6168)
tmp6483 = (tmp6484 if depth4 else tmp6168)
tmp6491 = (tmp6169 if depth7 else tmp6177)
tmp6490 = (tmp6491 if depth6 else tmp6168)
tmp6489 = (tmp6490 if depth5 else tmp6168)
tmp6488 = (tmp6489 if depth4 else tmp6168)
tmp6487 = (tmp6483 if depth3 else tmp6488)
tmp6486 = (tmp6483 if depth2 else tmp6487)
tmp6482 = (tmp6483 if depth1 else tmp6486)
tmp6495 = (tmp6077 if depth6 else tmp6180)
tmp6494 = (tmp6495 if depth5 else tmp6180)
tmp6493 = (tmp6494 if depth4 else tmp6180)
tmp6501 = (tmp6077 if depth7 else tmp6187)
tmp6500 = (tmp6501 if depth6 else tmp6180)
tmp6499 = (tmp6500 if depth5 else tmp6180)
tmp6498 = (tmp6499 if depth4 else tmp6180)
tmp6497 = (tmp6493 if depth3 else tmp6498)
tmp6496 = (tmp6493 if depth2 else tmp6497)
tmp6492 = (tmp6493 if depth1 else tmp6496)
tmp6481 = (tmp6482 if s0 else tmp6492)
tmp6458 = (tmp6459 if s1 else tmp6481)
tmp6414 = (tmp6415 if s2 else tmp6458)
tmp6509 = (tmp6073 if depth6 else tmp6072)
tmp6508 = (tmp6509 if depth5 else tmp6072)
tmp6507 = (tmp6508 if depth4 else tmp6420)
tmp6510 = (tmp6508 if depth4 else tmp6072)
tmp6506 = (tmp6507 if depth3 else tmp6510)
tmp6511 = (tmp6506 if depth2 else tmp6510)
tmp6505 = (tmp6506 if depth1 else tmp6511)
tmp6513 = (tmp6427 if depth3 else tmp6426)
tmp6516 = (tmp6427 if depth4 else tmp6432)
tmp6515 = (tmp6516 if depth3 else tmp6426)
tmp6514 = (tmp6513 if depth2 else tmp6515)
tmp6512 = (tmp6513 if depth1 else tmp6514)
tmp6504 = (tmp6505 if s0 else tmp6512)
tmp6519 = (tmp6439 if depth3 else tmp6438)
tmp6522 = (tmp6439 if depth4 else tmp6444)
tmp6521 = (tmp6522 if depth3 else tmp6438)
tmp6520 = (tmp6519 if depth2 else tmp6521)
tmp6518 = (tmp6519 if depth1 else tmp6520)
tmp6524 = (tmp6450 if depth3 else tmp6449)
tmp6527 = (tmp6450 if depth4 else tmp6455)
tmp6526 = (tmp6527 if depth3 else tmp6449)
tmp6525 = (tmp6524 if depth2 else tmp6526)
tmp6523 = (tmp6524 if depth1 else tmp6525)
tmp6517 = (tmp6518 if s0 else tmp6523)
tmp6503 = (tmp6504 if s1 else tmp6517)
tmp6532 = (tmp6463 if depth4 else tmp6466)
tmp6531 = (tmp6463 if depth3 else tmp6532)
tmp6534 = (tmp6463 if depth3 else tmp6462)
tmp6533 = (tmp6531 if depth2 else tmp6534)
tmp6530 = (tmp6531 if depth1 else tmp6533)
tmp6538 = (tmp6473 if depth4 else tmp6478)
tmp6537 = (tmp6473 if depth3 else tmp6538)
tmp6536 = (tmp6473 if depth2 else tmp6537)
tmp6535 = (tmp6473 if depth1 else tmp6536)
tmp6529 = (tmp6530 if s0 else tmp6535)
tmp6543 = (tmp6484 if depth4 else tmp6489)
tmp6542 = (tmp6484 if depth3 else tmp6543)
tmp6541 = (tmp6484 if depth2 else tmp6542)
tmp6540 = (tmp6484 if depth1 else tmp6541)
tmp6547 = (tmp6494 if depth4 else tmp6499)
tmp6546 = (tmp6494 if depth3 else tmp6547)
tmp6545 = (tmp6494 if depth2 else tmp6546)
tmp6544 = (tmp6494 if depth1 else tmp6545)
tmp6539 = (tmp6540 if s0 else tmp6544)
tmp6528 = (tmp6529 if s1 else tmp6539)
tmp6502 = (tmp6503 if s2 else tmp6528)
tmp6413 = (tmp6414 if s3 else tmp6502)
tmp6555 = (tmp6509 if depth5 else tmp6421)
tmp6554 = (tmp6555 if depth4 else tmp6508)
tmp6553 = (tmp6554 if depth3 else tmp6508)
tmp6556 = (tmp6553 if depth2 else tmp6508)
tmp6552 = (tmp6553 if depth1 else tmp6556)
tmp6559 = (tmp6428 if depth4 else tmp6427)
tmp6558 = (tmp6559 if depth3 else tmp6427)
tmp6563 = (tmp6428 if depth5 else tmp6433)
tmp6562 = (tmp6563 if depth4 else tmp6427)
tmp6561 = (tmp6562 if depth3 else tmp6427)
tmp6560 = (tmp6558 if depth2 else tmp6561)
tmp6557 = (tmp6558 if depth1 else tmp6560)
tmp6551 = (tmp6552 if s0 else tmp6557)
tmp6567 = (tmp6440 if depth4 else tmp6439)
tmp6566 = (tmp6567 if depth3 else tmp6439)
tmp6571 = (tmp6440 if depth5 else tmp6445)
tmp6570 = (tmp6571 if depth4 else tmp6439)
tmp6569 = (tmp6570 if depth3 else tmp6439)
tmp6568 = (tmp6566 if depth2 else tmp6569)
tmp6565 = (tmp6566 if depth1 else tmp6568)
tmp6574 = (tmp6451 if depth4 else tmp6450)
tmp6573 = (tmp6574 if depth3 else tmp6450)
tmp6578 = (tmp6451 if depth5 else tmp6456)
tmp6577 = (tmp6578 if depth4 else tmp6450)
tmp6576 = (tmp6577 if depth3 else tmp6450)
tmp6575 = (tmp6573 if depth2 else tmp6576)
tmp6572 = (tmp6573 if depth1 else tmp6575)
tmp6564 = (tmp6565 if s0 else tmp6572)
tmp6550 = (tmp6551 if s1 else tmp6564)
tmp6583 = (tmp6464 if depth4 else tmp6463)
tmp6585 = (tmp6464 if depth5 else tmp6467)
tmp6584 = (tmp6585 if depth4 else tmp6463)
tmp6582 = (tmp6583 if depth3 else tmp6584)
tmp6587 = (tmp6583 if depth3 else tmp6463)
tmp6586 = (tmp6582 if depth2 else tmp6587)
tmp6581 = (tmp6582 if depth1 else tmp6586)
tmp6589 = (tmp6474 if depth4 else tmp6473)
tmp6593 = (tmp6474 if depth5 else tmp6479)
tmp6592 = (tmp6593 if depth4 else tmp6473)
tmp6591 = (tmp6589 if depth3 else tmp6592)
tmp6590 = (tmp6589 if depth2 else tmp6591)
tmp6588 = (tmp6589 if depth1 else tmp6590)
tmp6580 = (tmp6581 if s0 else tmp6588)
tmp6596 = (tmp6485 if depth4 else tmp6484)
tmp6600 = (tmp6485 if depth5 else tmp6490)
tmp6599 = (tmp6600 if depth4 else tmp6484)
tmp6598 = (tmp6596 if depth3 else tmp6599)
tmp6597 = (tmp6596 if depth2 else tmp6598)
tmp6595 = (tmp6596 if depth1 else tmp6597)
tmp6602 = (tmp6495 if depth4 else tmp6494)
tmp6606 = (tmp6495 if depth5 else tmp6500)
tmp6605 = (tmp6606 if depth4 else tmp6494)
tmp6604 = (tmp6602 if depth3 else tmp6605)
tmp6603 = (tmp6602 if depth2 else tmp6604)
tmp6601 = (tmp6602 if depth1 else tmp6603)
tmp6594 = (tmp6595 if s0 else tmp6601)
tmp6579 = (tmp6580 if s1 else tmp6594)
tmp6549 = (tmp6550 if s2 else tmp6579)
tmp6612 = (tmp6509 if depth4 else tmp6555)
tmp6613 = (tmp6509 if depth4 else tmp6508)
tmp6611 = (tmp6612 if depth3 else tmp6613)
tmp6614 = (tmp6611 if depth2 else tmp6613)
tmp6610 = (tmp6611 if depth1 else tmp6614)
tmp6616 = (tmp6428 if depth3 else tmp6559)
tmp6619 = (tmp6428 if depth4 else tmp6563)
tmp6618 = (tmp6619 if depth3 else tmp6559)
tmp6617 = (tmp6616 if depth2 else tmp6618)
tmp6615 = (tmp6616 if depth1 else tmp6617)
tmp6609 = (tmp6610 if s0 else tmp6615)
tmp6622 = (tmp6440 if depth3 else tmp6567)
tmp6625 = (tmp6440 if depth4 else tmp6571)
tmp6624 = (tmp6625 if depth3 else tmp6567)
tmp6623 = (tmp6622 if depth2 else tmp6624)
tmp6621 = (tmp6622 if depth1 else tmp6623)
tmp6627 = (tmp6451 if depth3 else tmp6574)
tmp6630 = (tmp6451 if depth4 else tmp6578)
tmp6629 = (tmp6630 if depth3 else tmp6574)
tmp6628 = (tmp6627 if depth2 else tmp6629)
tmp6626 = (tmp6627 if depth1 else tmp6628)
tmp6620 = (tmp6621 if s0 else tmp6626)
tmp6608 = (tmp6609 if s1 else tmp6620)
tmp6635 = (tmp6464 if depth4 else tmp6585)
tmp6634 = (tmp6464 if depth3 else tmp6635)
tmp6637 = (tmp6464 if depth3 else tmp6583)
tmp6636 = (tmp6634 if depth2 else tmp6637)
tmp6633 = (tmp6634 if depth1 else tmp6636)
tmp6641 = (tmp6474 if depth4 else tmp6593)
tmp6640 = (tmp6474 if depth3 else tmp6641)
tmp6639 = (tmp6474 if depth2 else tmp6640)
tmp6638 = (tmp6474 if depth1 else tmp6639)
tmp6632 = (tmp6633 if s0 else tmp6638)
tmp6646 = (tmp6485 if depth4 else tmp6600)
tmp6645 = (tmp6485 if depth3 else tmp6646)
tmp6644 = (tmp6485 if depth2 else tmp6645)
tmp6643 = (tmp6485 if depth1 else tmp6644)
tmp6650 = (tmp6495 if depth4 else tmp6606)
tmp6649 = (tmp6495 if depth3 else tmp6650)
tmp6648 = (tmp6495 if depth2 else tmp6649)
tmp6647 = (tmp6495 if depth1 else tmp6648)
tmp6642 = (tmp6643 if s0 else tmp6647)
tmp6631 = (tmp6632 if s1 else tmp6642)
tmp6607 = (tmp6608 if s2 else tmp6631)
tmp6548 = (tmp6549 if s3 else tmp6607)
tmp6412 = (tmp6413 if s4 else tmp6548)
tmp6660 = (tmp6073 if depth6 else tmp6422)
tmp6659 = (tmp6660 if depth5 else tmp6509)
tmp6658 = (tmp6659 if depth4 else tmp6509)
tmp6657 = (tmp6658 if depth3 else tmp6509)
tmp6661 = (tmp6657 if depth2 else tmp6509)
tmp6656 = (tmp6657 if depth1 else tmp6661)
tmp6665 = (tmp6074 if depth5 else tmp6428)
tmp6664 = (tmp6665 if depth4 else tmp6428)
tmp6663 = (tmp6664 if depth3 else tmp6428)
tmp6670 = (tmp6074 if depth6 else tmp6434)
tmp6669 = (tmp6670 if depth5 else tmp6428)
tmp6668 = (tmp6669 if depth4 else tmp6428)
tmp6667 = (tmp6668 if depth3 else tmp6428)
tmp6666 = (tmp6663 if depth2 else tmp6667)
tmp6662 = (tmp6663 if depth1 else tmp6666)
tmp6655 = (tmp6656 if s0 else tmp6662)
tmp6675 = (tmp6110 if depth5 else tmp6440)
tmp6674 = (tmp6675 if depth4 else tmp6440)
tmp6673 = (tmp6674 if depth3 else tmp6440)
tmp6680 = (tmp6110 if depth6 else tmp6446)
tmp6679 = (tmp6680 if depth5 else tmp6440)
tmp6678 = (tmp6679 if depth4 else tmp6440)
tmp6677 = (tmp6678 if depth3 else tmp6440)
tmp6676 = (tmp6673 if depth2 else tmp6677)
tmp6672 = (tmp6673 if depth1 else tmp6676)
tmp6684 = (tmp6111 if depth5 else tmp6451)
tmp6683 = (tmp6684 if depth4 else tmp6451)
tmp6682 = (tmp6683 if depth3 else tmp6451)
tmp6689 = (tmp6111 if depth6 else tmp6457)
tmp6688 = (tmp6689 if depth5 else tmp6451)
tmp6687 = (tmp6688 if depth4 else tmp6451)
tmp6686 = (tmp6687 if depth3 else tmp6451)
tmp6685 = (tmp6682 if depth2 else tmp6686)
tmp6681 = (tmp6682 if depth1 else tmp6685)
tmp6671 = (tmp6672 if s0 else tmp6681)
tmp6654 = (tmp6655 if s1 else tmp6671)
tmp6695 = (tmp6142 if depth5 else tmp6464)
tmp6694 = (tmp6695 if depth4 else tmp6464)
tmp6698 = (tmp6142 if depth6 else tmp6468)
tmp6697 = (tmp6698 if depth5 else tmp6464)
tmp6696 = (tmp6697 if depth4 else tmp6464)
tmp6693 = (tmp6694 if depth3 else tmp6696)
tmp6700 = (tmp6694 if depth3 else tmp6464)
tmp6699 = (tmp6693 if depth2 else tmp6700)
tmp6692 = (tmp6693 if depth1 else tmp6699)
tmp6703 = (tmp6143 if depth5 else tmp6474)
tmp6702 = (tmp6703 if depth4 else tmp6474)
tmp6708 = (tmp6143 if depth6 else tmp6480)
tmp6707 = (tmp6708 if depth5 else tmp6474)
tmp6706 = (tmp6707 if depth4 else tmp6474)
tmp6705 = (tmp6702 if depth3 else tmp6706)
tmp6704 = (tmp6702 if depth2 else tmp6705)
tmp6701 = (tmp6702 if depth1 else tmp6704)
tmp6691 = (tmp6692 if s0 else tmp6701)
tmp6712 = (tmp6169 if depth5 else tmp6485)
tmp6711 = (tmp6712 if depth4 else tmp6485)
tmp6717 = (tmp6169 if depth6 else tmp6491)
tmp6716 = (tmp6717 if depth5 else tmp6485)
tmp6715 = (tmp6716 if depth4 else tmp6485)
tmp6714 = (tmp6711 if depth3 else tmp6715)
tmp6713 = (tmp6711 if depth2 else tmp6714)
tmp6710 = (tmp6711 if depth1 else tmp6713)
tmp6720 = (tmp6077 if depth5 else tmp6495)
tmp6719 = (tmp6720 if depth4 else tmp6495)
tmp6725 = (tmp6077 if depth6 else tmp6501)
tmp6724 = (tmp6725 if depth5 else tmp6495)
tmp6723 = (tmp6724 if depth4 else tmp6495)
tmp6722 = (tmp6719 if depth3 else tmp6723)
tmp6721 = (tmp6719 if depth2 else tmp6722)
tmp6718 = (tmp6719 if depth1 else tmp6721)
tmp6709 = (tmp6710 if s0 else tmp6718)
tmp6690 = (tmp6691 if s1 else tmp6709)
tmp6653 = (tmp6654 if s2 else tmp6690)
tmp6732 = (tmp6073 if depth5 else tmp6509)
tmp6731 = (tmp6732 if depth4 else tmp6659)
tmp6733 = (tmp6732 if depth4 else tmp6509)
tmp6730 = (tmp6731 if depth3 else tmp6733)
tmp6734 = (tmp6730 if depth2 else tmp6733)
tmp6729 = (tmp6730 if depth1 else tmp6734)
tmp6736 = (tmp6665 if depth3 else tmp6664)
tmp6739 = (tmp6665 if depth4 else tmp6669)
tmp6738 = (tmp6739 if depth3 else tmp6664)
tmp6737 = (tmp6736 if depth2 else tmp6738)
tmp6735 = (tmp6736 if depth1 else tmp6737)
tmp6728 = (tmp6729 if s0 else tmp6735)
tmp6742 = (tmp6675 if depth3 else tmp6674)
tmp6745 = (tmp6675 if depth4 else tmp6679)
tmp6744 = (tmp6745 if depth3 else tmp6674)
tmp6743 = (tmp6742 if depth2 else tmp6744)
tmp6741 = (tmp6742 if depth1 else tmp6743)
tmp6747 = (tmp6684 if depth3 else tmp6683)
tmp6750 = (tmp6684 if depth4 else tmp6688)
tmp6749 = (tmp6750 if depth3 else tmp6683)
tmp6748 = (tmp6747 if depth2 else tmp6749)
tmp6746 = (tmp6747 if depth1 else tmp6748)
tmp6740 = (tmp6741 if s0 else tmp6746)
tmp6727 = (tmp6728 if s1 else tmp6740)
tmp6755 = (tmp6695 if depth4 else tmp6697)
tmp6754 = (tmp6695 if depth3 else tmp6755)
tmp6757 = (tmp6695 if depth3 else tmp6694)
tmp6756 = (tmp6754 if depth2 else tmp6757)
tmp6753 = (tmp6754 if depth1 else tmp6756)
tmp6761 = (tmp6703 if depth4 else tmp6707)
tmp6760 = (tmp6703 if depth3 else tmp6761)
tmp6759 = (tmp6703 if depth2 else tmp6760)
tmp6758 = (tmp6703 if depth1 else tmp6759)
tmp6752 = (tmp6753 if s0 else tmp6758)
tmp6766 = (tmp6712 if depth4 else tmp6716)
tmp6765 = (tmp6712 if depth3 else tmp6766)
tmp6764 = (tmp6712 if depth2 else tmp6765)
tmp6763 = (tmp6712 if depth1 else tmp6764)
tmp6770 = (tmp6720 if depth4 else tmp6724)
tmp6769 = (tmp6720 if depth3 else tmp6770)
tmp6768 = (tmp6720 if depth2 else tmp6769)
tmp6767 = (tmp6720 if depth1 else tmp6768)
tmp6762 = (tmp6763 if s0 else tmp6767)
tmp6751 = (tmp6752 if s1 else tmp6762)
tmp6726 = (tmp6727 if s2 else tmp6751)
tmp6652 = (tmp6653 if s3 else tmp6726)
tmp6778 = (tmp6073 if depth5 else tmp6660)
tmp6777 = (tmp6778 if depth4 else tmp6732)
tmp6776 = (tmp6777 if depth3 else tmp6732)
tmp6779 = (tmp6776 if depth2 else tmp6732)
tmp6775 = (tmp6776 if depth1 else tmp6779)
tmp6782 = (tmp6074 if depth4 else tmp6665)
tmp6781 = (tmp6782 if depth3 else tmp6665)
tmp6786 = (tmp6074 if depth5 else tmp6670)
tmp6785 = (tmp6786 if depth4 else tmp6665)
tmp6784 = (tmp6785 if depth3 else tmp6665)
tmp6783 = (tmp6781 if depth2 else tmp6784)
tmp6780 = (tmp6781 if depth1 else tmp6783)
tmp6774 = (tmp6775 if s0 else tmp6780)
tmp6790 = (tmp6110 if depth4 else tmp6675)
tmp6789 = (tmp6790 if depth3 else tmp6675)
tmp6794 = (tmp6110 if depth5 else tmp6680)
tmp6793 = (tmp6794 if depth4 else tmp6675)
tmp6792 = (tmp6793 if depth3 else tmp6675)
tmp6791 = (tmp6789 if depth2 else tmp6792)
tmp6788 = (tmp6789 if depth1 else tmp6791)
tmp6797 = (tmp6111 if depth4 else tmp6684)
tmp6796 = (tmp6797 if depth3 else tmp6684)
tmp6801 = (tmp6111 if depth5 else tmp6689)
tmp6800 = (tmp6801 if depth4 else tmp6684)
tmp6799 = (tmp6800 if depth3 else tmp6684)
tmp6798 = (tmp6796 if depth2 else tmp6799)
tmp6795 = (tmp6796 if depth1 else tmp6798)
tmp6787 = (tmp6788 if s0 else tmp6795)
tmp6773 = (tmp6774 if s1 else tmp6787)
tmp6806 = (tmp6142 if depth4 else tmp6695)
tmp6808 = (tmp6142 if depth5 else tmp6698)
tmp6807 = (tmp6808 if depth4 else tmp6695)
tmp6805 = (tmp6806 if depth3 else tmp6807)
tmp6810 = (tmp6806 if depth3 else tmp6695)
tmp6809 = (tmp6805 if depth2 else tmp6810)
tmp6804 = (tmp6805 if depth1 else tmp6809)
tmp6812 = (tmp6143 if depth4 else tmp6703)
tmp6816 = (tmp6143 if depth5 else tmp6708)
tmp6815 = (tmp6816 if depth4 else tmp6703)
tmp6814 = (tmp6812 if depth3 else tmp6815)
tmp6813 = (tmp6812 if depth2 else tmp6814)
tmp6811 = (tmp6812 if depth1 else tmp6813)
tmp6803 = (tmp6804 if s0 else tmp6811)
tmp6819 = (tmp6169 if depth4 else tmp6712)
tmp6823 = (tmp6169 if depth5 else tmp6717)
tmp6822 = (tmp6823 if depth4 else tmp6712)
tmp6821 = (tmp6819 if depth3 else tmp6822)
tmp6820 = (tmp6819 if depth2 else tmp6821)
tmp6818 = (tmp6819 if depth1 else tmp6820)
tmp6825 = (tmp6077 if depth4 else tmp6720)
tmp6829 = (tmp6077 if depth5 else tmp6725)
tmp6828 = (tmp6829 if depth4 else tmp6720)
tmp6827 = (tmp6825 if depth3 else tmp6828)
tmp6826 = (tmp6825 if depth2 else tmp6827)
tmp6824 = (tmp6825 if depth1 else tmp6826)
tmp6817 = (tmp6818 if s0 else tmp6824)
tmp6802 = (tmp6803 if s1 else tmp6817)
tmp6772 = (tmp6773 if s2 else tmp6802)
tmp6835 = (tmp6073 if depth4 else tmp6778)
tmp6836 = (tmp6073 if depth4 else tmp6732)
tmp6834 = (tmp6835 if depth3 else tmp6836)
tmp6837 = (tmp6834 if depth2 else tmp6836)
tmp6833 = (tmp6834 if depth1 else tmp6837)
tmp6839 = (tmp6074 if depth3 else tmp6782)
tmp6842 = (tmp6074 if depth4 else tmp6786)
tmp6841 = (tmp6842 if depth3 else tmp6782)
tmp6840 = (tmp6839 if depth2 else tmp6841)
tmp6838 = (tmp6839 if depth1 else tmp6840)
tmp6832 = (tmp6833 if s0 else tmp6838)
tmp6845 = (tmp6110 if depth3 else tmp6790)
tmp6848 = (tmp6110 if depth4 else tmp6794)
tmp6847 = (tmp6848 if depth3 else tmp6790)
tmp6846 = (tmp6845 if depth2 else tmp6847)
tmp6844 = (tmp6845 if depth1 else tmp6846)
tmp6850 = (tmp6111 if depth3 else tmp6797)
tmp6853 = (tmp6111 if depth4 else tmp6801)
tmp6852 = (tmp6853 if depth3 else tmp6797)
tmp6851 = (tmp6850 if depth2 else tmp6852)
tmp6849 = (tmp6850 if depth1 else tmp6851)
tmp6843 = (tmp6844 if s0 else tmp6849)
tmp6831 = (tmp6832 if s1 else tmp6843)
tmp6857 = (1 if k1 else tmp6111)
tmp6862 = (1 if k1 else tmp6113)
tmp6861 = (tmp6857 if depth7 else tmp6862)
tmp6860 = (tmp6857 if depth6 else tmp6861)
tmp6859 = (tmp6857 if depth5 else tmp6860)
tmp6858 = (tmp6857 if depth4 else tmp6859)
tmp6856 = (tmp6857 if depth3 else tmp6858)
tmp6855 = (tmp6856 if s0 else 1)
tmp6854 = (tmp6855 if s1 else 1)
tmp6830 = (tmp6831 if s2 else tmp6854)
tmp6771 = (tmp6772 if s3 else tmp6830)
tmp6651 = (tmp6652 if s4 else tmp6771)
tmp6411 = (tmp6412 if s5 else tmp6651)
tmp6031 = (tmp6032 if s6 else tmp6411)
tmp6011 = (1 - (tmp6012 if s7 else tmp6031))
s2n = tmp6011
tmp6869 = (1 - (1 if oxygen_low else 0))
tmp6868 = (1 if oxygen_full else tmp6869)
tmp6867 = (1 if k2 else tmp6868)
tmp6873 = (1 if oxygen_full else 0)
tmp6872 = (tmp6873 if k2 else 1)
tmp6874 = (1 if k2 else tmp6873)
tmp6871 = (tmp6872 if k1 else tmp6874)
tmp6870 = (tmp6871 if s0 else tmp6872)
tmp6866 = (tmp6867 if s1 else tmp6870)
tmp6877 = (tmp6874 if k1 else tmp6872)
tmp6876 = (tmp6877 if s0 else tmp6874)
tmp6875 = (tmp6876 if s1 else tmp6870)
tmp6865 = (tmp6866 if s4 else tmp6875)
tmp6864 = (tmp6865 if s6 else tmp6875)
tmp6885 = (1 if k1 else tmp6874)
tmp6884 = (tmp6885 if s0 else 1)
tmp6883 = (tmp6876 if s1 else tmp6884)
tmp6898 = (1 if action1_1 else 0)
tmp6897 = (1 if action2_1 else tmp6898)
tmp6896 = (1 if action3_1 else tmp6897)
tmp6895 = (tmp6896 if action4_1 else 0)
tmp6903 = (1 - (1 if action1_1 else 0))
tmp6902 = (tmp6898 if action2_1 else tmp6903)
tmp6904 = (1 if action2_1 else tmp6903)
tmp6901 = (tmp6902 if action3_1 else tmp6904)
tmp6900 = (1 if action4_1 else tmp6901)
tmp6899 = (tmp6900 if oxygen_low else tmp6895)
tmp6894 = (tmp6895 if oxygen_full else tmp6899)
tmp6907 = (1 - (tmp6896 if action4_1 else 0))
tmp6906 = (1 - (tmp6900 if oxygen_low else tmp6907))
tmp6905 = (tmp6895 if oxygen_full else tmp6906)
tmp6893 = (tmp6894 if k2 else tmp6905)
tmp6910 = (1 - (tmp6895 if oxygen_low else tmp6907))
tmp6909 = (tmp6895 if oxygen_full else tmp6910)
tmp6908 = (tmp6895 if k2 else tmp6909)
tmp6892 = (tmp6893 if depth7 else tmp6908)
tmp6891 = (tmp6892 if depth6 else tmp6908)
tmp6914 = (tmp6894 if k2 else tmp6909)
tmp6913 = (tmp6914 if depth7 else tmp6908)
tmp6912 = (tmp6913 if depth6 else tmp6908)
tmp6911 = (tmp6891 if depth5 else tmp6912)
tmp6890 = (tmp6891 if depth4 else tmp6911)
tmp6924 = (1 - (tmp6902 if action3_1 else tmp6904))
tmp6923 = (tmp6896 if action4_1 else tmp6924)
tmp6922 = (tmp6895 if oxygen_low else tmp6923)
tmp6921 = (tmp6895 if oxygen_full else tmp6922)
tmp6927 = (1 - (tmp6896 if action4_1 else tmp6924))
tmp6926 = (1 - (tmp6895 if oxygen_low else tmp6927))
tmp6925 = (tmp6895 if oxygen_full else tmp6926)
tmp6920 = (tmp6921 if k2 else tmp6925)
tmp6919 = (tmp6908 if diver_found else tmp6920)
tmp6918 = (tmp6908 if depth7 else tmp6919)
tmp6917 = (tmp6908 if depth6 else tmp6918)
tmp6916 = (tmp6891 if depth5 else tmp6917)
tmp6915 = (tmp6891 if depth4 else tmp6916)
tmp6889 = (tmp6890 if depth3 else tmp6915)
tmp6930 = (tmp6891 if depth5 else tmp6908)
tmp6929 = (tmp6891 if depth4 else tmp6930)
tmp6928 = (tmp6929 if depth3 else tmp6915)
tmp6888 = (tmp6889 if depth2 else tmp6928)
tmp6937 = (tmp6914 if k1 else tmp6908)
tmp6936 = (tmp6937 if depth7 else tmp6908)
tmp6935 = (tmp6936 if depth6 else tmp6908)
tmp6934 = (tmp6891 if depth5 else tmp6935)
tmp6933 = (tmp6891 if depth4 else tmp6934)
tmp6932 = (tmp6933 if depth3 else tmp6915)
tmp6943 = (tmp6893 if k1 else tmp6914)
tmp6942 = (tmp6943 if depth7 else tmp6908)
tmp6941 = (tmp6942 if depth6 else tmp6908)
tmp6940 = (tmp6891 if depth5 else tmp6941)
tmp6939 = (tmp6940 if depth4 else tmp6916)
tmp6938 = (tmp6915 if depth3 else tmp6939)
tmp6931 = (tmp6932 if depth2 else tmp6938)
tmp6887 = (1 - (tmp6888 if depth1 else tmp6931))
tmp6886 = (1 if s1 else tmp6887)
tmp6882 = (tmp6883 if s2 else tmp6886)
tmp6956 = (1 - (1 if action4_1 else tmp6901))
tmp6955 = (tmp6895 if oxygen_full else tmp6956)
tmp6957 = (tmp6895 if oxygen_full else tmp6900)
tmp6954 = (tmp6955 if k2 else tmp6957)
tmp6958 = (tmp6957 if k2 else tmp6955)
tmp6953 = (tmp6954 if k1 else tmp6958)
tmp6961 = (tmp6895 if oxygen_full else tmp6907)
tmp6960 = (tmp6961 if k2 else tmp6895)
tmp6962 = (tmp6895 if k2 else tmp6961)
tmp6959 = (tmp6960 if k1 else tmp6962)
tmp6952 = (tmp6953 if depth7 else tmp6959)
tmp6951 = (tmp6952 if depth6 else tmp6959)
tmp6967 = (tmp6957 if k2 else tmp6961)
tmp6966 = (tmp6954 if k1 else tmp6967)
tmp6965 = (tmp6966 if depth7 else tmp6959)
tmp6964 = (tmp6965 if depth6 else tmp6959)
tmp6963 = (tmp6951 if depth5 else tmp6964)
tmp6950 = (tmp6951 if depth4 else tmp6963)
tmp6969 = (tmp6951 if depth5 else tmp6959)
tmp6968 = (tmp6951 if depth4 else tmp6969)
tmp6949 = (tmp6950 if depth3 else tmp6968)
tmp6976 = (tmp6955 if k2 else tmp6895)
tmp6975 = (tmp6976 if k1 else tmp6962)
tmp6974 = (tmp6975 if depth7 else tmp6959)
tmp6973 = (tmp6974 if depth6 else tmp6959)
tmp6972 = (tmp6951 if depth5 else tmp6973)
tmp6971 = (tmp6951 if depth4 else tmp6972)
tmp6970 = (tmp6971 if depth3 else tmp6968)
tmp6948 = (tmp6949 if depth2 else tmp6970)
tmp6983 = (tmp6976 if k1 else tmp6967)
tmp6982 = (tmp6983 if depth7 else tmp6959)
tmp6981 = (tmp6982 if depth6 else tmp6959)
tmp6980 = (tmp6951 if depth5 else tmp6981)
tmp6979 = (tmp6951 if depth4 else tmp6980)
tmp6978 = (tmp6979 if depth3 else tmp6968)
tmp6977 = (tmp6978 if depth2 else tmp6968)
tmp6947 = (tmp6948 if depth1 else tmp6977)
tmp6988 = (tmp6954 if depth7 else tmp6960)
tmp6987 = (tmp6988 if depth6 else tmp6960)
tmp6990 = (tmp6987 if depth5 else tmp6960)
tmp6989 = (tmp6987 if depth4 else tmp6990)
tmp6986 = (tmp6987 if depth3 else tmp6989)
tmp6995 = (tmp6976 if depth7 else tmp6960)
tmp6994 = (tmp6995 if depth6 else tmp6960)
tmp6993 = (tmp6987 if depth5 else tmp6994)
tmp6992 = (tmp6987 if depth4 else tmp6993)
tmp6991 = (tmp6992 if depth3 else tmp6989)
tmp6985 = (tmp6986 if depth2 else tmp6991)
tmp7002 = (tmp6954 if k1 else tmp6976)
tmp7001 = (tmp7002 if depth7 else tmp6960)
tmp7000 = (tmp7001 if depth6 else tmp6960)
tmp6999 = (tmp6987 if depth5 else tmp7000)
tmp6998 = (tmp6987 if depth4 else tmp6999)
tmp6997 = (tmp6998 if depth3 else tmp6989)
tmp7008 = (tmp6976 if k1 else tmp6960)
tmp7007 = (tmp7008 if depth7 else tmp6960)
tmp7006 = (tmp7007 if depth6 else tmp6960)
tmp7005 = (tmp6987 if depth5 else tmp7006)
tmp7004 = (tmp6987 if depth4 else tmp7005)
tmp7003 = (tmp7004 if depth3 else tmp6989)
tmp6996 = (tmp6997 if depth2 else tmp7003)
tmp6984 = (tmp6985 if depth1 else tmp6996)
tmp6946 = (tmp6947 if s0 else tmp6984)
tmp7015 = (tmp6958 if k1 else tmp6954)
tmp7016 = (tmp6962 if k1 else tmp6960)
tmp7014 = (tmp7015 if depth7 else tmp7016)
tmp7013 = (tmp7014 if depth6 else tmp7016)
tmp7021 = (tmp6967 if k1 else tmp6960)
tmp7020 = (tmp7021 if depth7 else tmp7016)
tmp7019 = (tmp7020 if depth6 else tmp7016)
tmp7018 = (tmp7013 if depth5 else tmp7019)
tmp7017 = (tmp7013 if depth4 else tmp7018)
tmp7012 = (tmp7013 if depth3 else tmp7017)
tmp7027 = (tmp6958 if k1 else tmp6976)
tmp7026 = (tmp7027 if depth7 else tmp7016)
tmp7025 = (tmp7026 if depth6 else tmp7016)
tmp7024 = (tmp7013 if depth5 else tmp7025)
tmp7023 = (tmp7013 if depth4 else tmp7024)
tmp7029 = (tmp7013 if depth5 else tmp7016)
tmp7028 = (tmp7013 if depth4 else tmp7029)
tmp7022 = (tmp7023 if depth3 else tmp7028)
tmp7011 = (tmp7012 if depth2 else tmp7022)
tmp7031 = (tmp7013 if depth3 else tmp7028)
tmp7037 = (tmp6967 if k1 else tmp6976)
tmp7036 = (tmp7037 if depth7 else tmp7016)
tmp7035 = (tmp7036 if depth6 else tmp7016)
tmp7034 = (tmp7013 if depth5 else tmp7035)
tmp7033 = (tmp7013 if depth4 else tmp7034)
tmp7032 = (tmp7033 if depth3 else tmp7028)
tmp7030 = (tmp7031 if depth2 else tmp7032)
tmp7010 = (tmp7011 if depth1 else tmp7030)
tmp7042 = (tmp6958 if depth7 else tmp6962)
tmp7041 = (tmp7042 if depth6 else tmp6962)
tmp7046 = (tmp6967 if depth7 else tmp6962)
tmp7045 = (tmp7046 if depth6 else tmp6962)
tmp7044 = (tmp7041 if depth5 else tmp7045)
tmp7043 = (tmp7041 if depth4 else tmp7044)
tmp7040 = (tmp7041 if depth3 else tmp7043)
tmp7049 = (tmp7041 if depth5 else tmp6962)
tmp7048 = (tmp7041 if depth4 else tmp7049)
tmp7047 = (tmp7041 if depth3 else tmp7048)
tmp7039 = (tmp7040 if depth2 else tmp7047)
tmp7056 = (tmp6967 if k1 else tmp6962)
tmp7055 = (tmp7056 if depth7 else tmp6962)
tmp7054 = (tmp7055 if depth6 else tmp6962)
tmp7053 = (tmp7041 if depth5 else tmp7054)
tmp7052 = (tmp7041 if depth4 else tmp7053)
tmp7051 = (tmp7041 if depth3 else tmp7052)
tmp7062 = (tmp6958 if k1 else tmp6967)
tmp7061 = (tmp7062 if depth7 else tmp6962)
tmp7060 = (tmp7061 if depth6 else tmp6962)
tmp7059 = (tmp7041 if depth5 else tmp7060)
tmp7058 = (tmp7041 if depth4 else tmp7059)
tmp7057 = (tmp7058 if depth3 else tmp7048)
tmp7050 = (tmp7051 if depth2 else tmp7057)
tmp7038 = (tmp7039 if depth1 else tmp7050)
tmp7009 = (tmp7010 if s0 else tmp7038)
tmp6945 = (tmp6946 if s1 else tmp7009)
tmp7067 = (tmp6951 if depth3 else tmp6950)
tmp7068 = (tmp6951 if depth3 else tmp6971)
tmp7066 = (tmp7067 if depth2 else tmp7068)
tmp7070 = (tmp6951 if depth3 else tmp6979)
tmp7071 = (tmp6951 if depth3 else tmp6968)
tmp7069 = (tmp7070 if depth2 else tmp7071)
tmp7065 = (tmp7066 if depth1 else tmp7069)
tmp7074 = (tmp6987 if depth3 else tmp6992)
tmp7073 = (tmp6987 if depth2 else tmp7074)
tmp7076 = (tmp6987 if depth3 else tmp6998)
tmp7077 = (tmp6987 if depth3 else tmp7004)
tmp7075 = (tmp7076 if depth2 else tmp7077)
tmp7072 = (tmp7073 if depth1 else tmp7075)
tmp7064 = (tmp7065 if s0 else tmp7072)
tmp7084 = (tmp7014 if depth6 else tmp7020)
tmp7083 = (tmp7084 if depth5 else tmp7013)
tmp7082 = (tmp7083 if depth4 else tmp7013)
tmp7081 = (tmp7082 if depth3 else tmp7013)
tmp7085 = (tmp7013 if depth3 else tmp7023)
tmp7080 = (tmp7081 if depth2 else tmp7085)
tmp7087 = (tmp7013 if depth3 else tmp7033)
tmp7086 = (tmp7013 if depth2 else tmp7087)
tmp7079 = (tmp7080 if depth1 else tmp7086)
tmp7093 = (tmp7042 if depth6 else tmp7046)
tmp7092 = (tmp7093 if depth5 else tmp7041)
tmp7091 = (tmp7092 if depth4 else tmp7041)
tmp7090 = (tmp7091 if depth3 else tmp7041)
tmp7089 = (tmp7090 if depth2 else tmp7041)
tmp7098 = (tmp7042 if depth6 else tmp7055)
tmp7097 = (tmp7098 if depth5 else tmp7041)
tmp7096 = (tmp7097 if depth4 else tmp7041)
tmp7095 = (tmp7096 if depth3 else tmp7041)
tmp7099 = (tmp7041 if depth3 else tmp7058)
tmp7094 = (tmp7095 if depth2 else tmp7099)
tmp7088 = (tmp7089 if depth1 else tmp7094)
tmp7078 = (tmp7079 if s0 else tmp7088)
tmp7063 = (tmp7064 if s1 else tmp7078)
tmp6944 = (1 - (tmp6945 if s2 else tmp7063))
tmp6881 = (tmp6882 if s3 else tmp6944)
tmp6880 = (tmp6875 if s4 else tmp6881)
tmp7110 = (tmp6952 if depth6 else tmp6965)
tmp7109 = (tmp7110 if depth5 else tmp6951)
tmp7108 = (tmp7109 if depth4 else tmp6951)
tmp7107 = (tmp7108 if depth3 else tmp6951)
tmp7114 = (tmp6952 if depth6 else tmp6974)
tmp7113 = (tmp7114 if depth5 else tmp6951)
tmp7112 = (tmp7113 if depth4 else tmp6951)
tmp7111 = (tmp7112 if depth3 else tmp6951)
tmp7106 = (tmp7107 if depth2 else tmp7111)
tmp7119 = (tmp6952 if depth6 else tmp6982)
tmp7118 = (tmp7119 if depth5 else tmp6951)
tmp7117 = (tmp7118 if depth4 else tmp6951)
tmp7116 = (tmp7117 if depth3 else tmp6951)
tmp7115 = (tmp7116 if depth2 else tmp6951)
tmp7105 = (tmp7106 if depth1 else tmp7115)
tmp7124 = (tmp6988 if depth5 else tmp6987)
tmp7123 = (tmp7124 if depth4 else tmp6987)
tmp7122 = (tmp7123 if depth3 else tmp6987)
tmp7128 = (tmp6988 if depth6 else tmp6995)
tmp7127 = (tmp7128 if depth5 else tmp6987)
tmp7126 = (tmp7127 if depth4 else tmp6987)
tmp7125 = (tmp7126 if depth3 else tmp6987)
tmp7121 = (tmp7122 if depth2 else tmp7125)
tmp7133 = (tmp6988 if depth6 else tmp7001)
tmp7132 = (tmp7133 if depth5 else tmp6987)
tmp7131 = (tmp7132 if depth4 else tmp6987)
tmp7130 = (tmp7131 if depth3 else tmp6987)
tmp7137 = (tmp6988 if depth6 else tmp7007)
tmp7136 = (tmp7137 if depth5 else tmp6987)
tmp7135 = (tmp7136 if depth4 else tmp6987)
tmp7134 = (tmp7135 if depth3 else tmp6987)
tmp7129 = (tmp7130 if depth2 else tmp7134)
tmp7120 = (tmp7121 if depth1 else tmp7129)
tmp7104 = (tmp7105 if s0 else tmp7120)
tmp7143 = (tmp7014 if depth5 else tmp7013)
tmp7142 = (tmp7143 if depth4 else tmp7013)
tmp7141 = (tmp7142 if depth3 else tmp7082)
tmp7147 = (tmp7014 if depth6 else tmp7026)
tmp7146 = (tmp7147 if depth5 else tmp7013)
tmp7145 = (tmp7146 if depth4 else tmp7013)
tmp7144 = (tmp7145 if depth3 else tmp7013)
tmp7140 = (tmp7141 if depth2 else tmp7144)
tmp7149 = (tmp7142 if depth3 else tmp7013)
tmp7153 = (tmp7014 if depth6 else tmp7036)
tmp7152 = (tmp7153 if depth5 else tmp7013)
tmp7151 = (tmp7152 if depth4 else tmp7013)
tmp7150 = (tmp7151 if depth3 else tmp7013)
tmp7148 = (tmp7149 if depth2 else tmp7150)
tmp7139 = (tmp7140 if depth1 else tmp7148)
tmp7158 = (tmp7042 if depth5 else tmp7041)
tmp7157 = (tmp7158 if depth4 else tmp7041)
tmp7156 = (tmp7157 if depth3 else tmp7091)
tmp7159 = (tmp7157 if depth3 else tmp7041)
tmp7155 = (tmp7156 if depth2 else tmp7159)
tmp7161 = (tmp7157 if depth3 else tmp7096)
tmp7165 = (tmp7042 if depth6 else tmp7061)
tmp7164 = (tmp7165 if depth5 else tmp7041)
tmp7163 = (tmp7164 if depth4 else tmp7041)
tmp7162 = (tmp7163 if depth3 else tmp7041)
tmp7160 = (tmp7161 if depth2 else tmp7162)
tmp7154 = (tmp7155 if depth1 else tmp7160)
tmp7138 = (tmp7139 if s0 else tmp7154)
tmp7103 = (tmp7104 if s1 else tmp7138)
tmp7172 = (tmp6952 if depth5 else tmp6951)
tmp7171 = (tmp7172 if depth4 else tmp6951)
tmp7170 = (tmp7171 if depth3 else tmp7108)
tmp7173 = (tmp7171 if depth3 else tmp7112)
tmp7169 = (tmp7170 if depth2 else tmp7173)
tmp7175 = (tmp7171 if depth3 else tmp7117)
tmp7176 = (tmp7171 if depth3 else tmp6951)
tmp7174 = (tmp7175 if depth2 else tmp7176)
tmp7168 = (tmp7169 if depth1 else tmp7174)
tmp7179 = (tmp7123 if depth3 else tmp7126)
tmp7178 = (tmp7123 if depth2 else tmp7179)
tmp7181 = (tmp7123 if depth3 else tmp7131)
tmp7182 = (tmp7123 if depth3 else tmp7135)
tmp7180 = (tmp7181 if depth2 else tmp7182)
tmp7177 = (tmp7178 if depth1 else tmp7180)
tmp7167 = (tmp7168 if s0 else tmp7177)
tmp7187 = (tmp7143 if depth4 else tmp7083)
tmp7186 = (tmp7187 if depth3 else tmp7142)
tmp7188 = (tmp7142 if depth3 else tmp7145)
tmp7185 = (tmp7186 if depth2 else tmp7188)
tmp7190 = (tmp7142 if depth3 else tmp7151)
tmp7189 = (tmp7142 if depth2 else tmp7190)
tmp7184 = (tmp7185 if depth1 else tmp7189)
tmp7194 = (tmp7158 if depth4 else tmp7092)
tmp7193 = (tmp7194 if depth3 else tmp7157)
tmp7192 = (tmp7193 if depth2 else tmp7157)
tmp7197 = (tmp7158 if depth4 else tmp7097)
tmp7196 = (tmp7197 if depth3 else tmp7157)
tmp7198 = (tmp7157 if depth3 else tmp7163)
tmp7195 = (tmp7196 if depth2 else tmp7198)
tmp7191 = (tmp7192 if depth1 else tmp7195)
tmp7183 = (tmp7184 if s0 else tmp7191)
tmp7166 = (tmp7167 if s1 else tmp7183)
tmp7102 = (tmp7103 if s2 else tmp7166)
tmp7205 = (tmp7172 if depth4 else tmp7109)
tmp7204 = (tmp7205 if depth3 else tmp7171)
tmp7207 = (tmp7172 if depth4 else tmp7113)
tmp7206 = (tmp7207 if depth3 else tmp7171)
tmp7203 = (tmp7204 if depth2 else tmp7206)
tmp7210 = (tmp7172 if depth4 else tmp7118)
tmp7209 = (tmp7210 if depth3 else tmp7171)
tmp7208 = (tmp7209 if depth2 else tmp7171)
tmp7202 = (tmp7203 if depth1 else tmp7208)
tmp7213 = (tmp7124 if depth3 else tmp7123)
tmp7215 = (tmp7124 if depth4 else tmp7127)
tmp7214 = (tmp7215 if depth3 else tmp7123)
tmp7212 = (tmp7213 if depth2 else tmp7214)
tmp7218 = (tmp7124 if depth4 else tmp7132)
tmp7217 = (tmp7218 if depth3 else tmp7123)
tmp7220 = (tmp7124 if depth4 else tmp7136)
tmp7219 = (tmp7220 if depth3 else tmp7123)
tmp7216 = (tmp7217 if depth2 else tmp7219)
tmp7211 = (tmp7212 if depth1 else tmp7216)
tmp7201 = (tmp7202 if s0 else tmp7211)
tmp7224 = (tmp7143 if depth3 else tmp7187)
tmp7226 = (tmp7143 if depth4 else tmp7146)
tmp7225 = (tmp7226 if depth3 else tmp7142)
tmp7223 = (tmp7224 if depth2 else tmp7225)
tmp7228 = (tmp7143 if depth3 else tmp7142)
tmp7230 = (tmp7143 if depth4 else tmp7152)
tmp7229 = (tmp7230 if depth3 else tmp7142)
tmp7227 = (tmp7228 if depth2 else tmp7229)
tmp7222 = (tmp7223 if depth1 else tmp7227)
tmp7233 = (tmp7158 if depth3 else tmp7194)
tmp7234 = (tmp7158 if depth3 else tmp7157)
tmp7232 = (tmp7233 if depth2 else tmp7234)
tmp7236 = (tmp7158 if depth3 else tmp7197)
tmp7238 = (tmp7158 if depth4 else tmp7164)
tmp7237 = (tmp7238 if depth3 else tmp7157)
tmp7235 = (tmp7236 if depth2 else tmp7237)
tmp7231 = (tmp7232 if depth1 else tmp7235)
tmp7221 = (tmp7222 if s0 else tmp7231)
tmp7200 = (tmp7201 if s1 else tmp7221)
tmp7243 = (tmp7172 if depth3 else tmp7205)
tmp7244 = (tmp7172 if depth3 else tmp7207)
tmp7242 = (tmp7243 if depth2 else tmp7244)
tmp7246 = (tmp7172 if depth3 else tmp7210)
tmp7247 = (tmp7172 if depth3 else tmp7171)
tmp7245 = (tmp7246 if depth2 else tmp7247)
tmp7241 = (tmp7242 if depth1 else tmp7245)
tmp7250 = (tmp7124 if depth3 else tmp7215)
tmp7249 = (tmp7124 if depth2 else tmp7250)
tmp7252 = (tmp7124 if depth3 else tmp7218)
tmp7253 = (tmp7124 if depth3 else tmp7220)
tmp7251 = (tmp7252 if depth2 else tmp7253)
tmp7248 = (tmp7249 if depth1 else tmp7251)
tmp7240 = (tmp7241 if s0 else tmp7248)
tmp7259 = (tmp7014 if depth5 else tmp7084)
tmp7258 = (tmp7259 if depth4 else tmp7143)
tmp7257 = (tmp7258 if depth3 else tmp7143)
tmp7260 = (tmp7143 if depth3 else tmp7226)
tmp7256 = (tmp7257 if depth2 else tmp7260)
tmp7262 = (tmp7143 if depth3 else tmp7230)
tmp7261 = (tmp7143 if depth2 else tmp7262)
tmp7255 = (tmp7256 if depth1 else tmp7261)
tmp7267 = (tmp7042 if depth5 else tmp7093)
tmp7266 = (tmp7267 if depth4 else tmp7158)
tmp7265 = (tmp7266 if depth3 else tmp7158)
tmp7264 = (tmp7265 if depth2 else tmp7158)
tmp7271 = (tmp7042 if depth5 else tmp7098)
tmp7270 = (tmp7271 if depth4 else tmp7158)
tmp7269 = (tmp7270 if depth3 else tmp7158)
tmp7272 = (tmp7158 if depth3 else tmp7238)
tmp7268 = (tmp7269 if depth2 else tmp7272)
tmp7263 = (tmp7264 if depth1 else tmp7268)
tmp7254 = (tmp7255 if s0 else tmp7263)
tmp7239 = (tmp7240 if s1 else tmp7254)
tmp7199 = (tmp7200 if s2 else tmp7239)
tmp7101 = (tmp7102 if s3 else tmp7199)
tmp7281 = (tmp6952 if depth5 else tmp7110)
tmp7280 = (tmp7281 if depth4 else tmp7172)
tmp7279 = (tmp7280 if depth3 else tmp7172)
tmp7284 = (tmp6952 if depth5 else tmp7114)
tmp7283 = (tmp7284 if depth4 else tmp7172)
tmp7282 = (tmp7283 if depth3 else tmp7172)
tmp7278 = (tmp7279 if depth2 else tmp7282)
tmp7288 = (tmp6952 if depth5 else tmp7119)
tmp7287 = (tmp7288 if depth4 else tmp7172)
tmp7286 = (tmp7287 if depth3 else tmp7172)
tmp7285 = (tmp7286 if depth2 else tmp7172)
tmp7277 = (tmp7278 if depth1 else tmp7285)
tmp7292 = (tmp6988 if depth4 else tmp7124)
tmp7291 = (tmp7292 if depth3 else tmp7124)
tmp7295 = (tmp6988 if depth5 else tmp7128)
tmp7294 = (tmp7295 if depth4 else tmp7124)
tmp7293 = (tmp7294 if depth3 else tmp7124)
tmp7290 = (tmp7291 if depth2 else tmp7293)
tmp7299 = (tmp6988 if depth5 else tmp7133)
tmp7298 = (tmp7299 if depth4 else tmp7124)
tmp7297 = (tmp7298 if depth3 else tmp7124)
tmp7302 = (tmp6988 if depth5 else tmp7137)
tmp7301 = (tmp7302 if depth4 else tmp7124)
tmp7300 = (tmp7301 if depth3 else tmp7124)
tmp7296 = (tmp7297 if depth2 else tmp7300)
tmp7289 = (tmp7290 if depth1 else tmp7296)
tmp7276 = (tmp7277 if s0 else tmp7289)
tmp7307 = (tmp7014 if depth4 else tmp7143)
tmp7306 = (tmp7307 if depth3 else tmp7258)
tmp7310 = (tmp7014 if depth5 else tmp7147)
tmp7309 = (tmp7310 if depth4 else tmp7143)
tmp7308 = (tmp7309 if depth3 else tmp7143)
tmp7305 = (tmp7306 if depth2 else tmp7308)
tmp7312 = (tmp7307 if depth3 else tmp7143)
tmp7315 = (tmp7014 if depth5 else tmp7153)
tmp7314 = (tmp7315 if depth4 else tmp7143)
tmp7313 = (tmp7314 if depth3 else tmp7143)
tmp7311 = (tmp7312 if depth2 else tmp7313)
tmp7304 = (tmp7305 if depth1 else tmp7311)
tmp7319 = (tmp7042 if depth4 else tmp7158)
tmp7318 = (tmp7319 if depth3 else tmp7266)
tmp7320 = (tmp7319 if depth3 else tmp7158)
tmp7317 = (tmp7318 if depth2 else tmp7320)
tmp7322 = (tmp7319 if depth3 else tmp7270)
tmp7325 = (tmp7042 if depth5 else tmp7165)
tmp7324 = (tmp7325 if depth4 else tmp7158)
tmp7323 = (tmp7324 if depth3 else tmp7158)
tmp7321 = (tmp7322 if depth2 else tmp7323)
tmp7316 = (tmp7317 if depth1 else tmp7321)
tmp7303 = (tmp7304 if s0 else tmp7316)
tmp7275 = (tmp7276 if s1 else tmp7303)
tmp7331 = (tmp6952 if depth4 else tmp7172)
tmp7330 = (tmp7331 if depth3 else tmp7280)
tmp7332 = (tmp7331 if depth3 else tmp7283)
tmp7329 = (tmp7330 if depth2 else tmp7332)
tmp7334 = (tmp7331 if depth3 else tmp7287)
tmp7335 = (tmp7331 if depth3 else tmp7172)
tmp7333 = (tmp7334 if depth2 else tmp7335)
tmp7328 = (tmp7329 if depth1 else tmp7333)
tmp7338 = (tmp7292 if depth3 else tmp7294)
tmp7337 = (tmp7292 if depth2 else tmp7338)
tmp7340 = (tmp7292 if depth3 else tmp7298)
tmp7341 = (tmp7292 if depth3 else tmp7301)
tmp7339 = (tmp7340 if depth2 else tmp7341)
tmp7336 = (tmp7337 if depth1 else tmp7339)
tmp7327 = (tmp7328 if s0 else tmp7336)
tmp7346 = (tmp7014 if depth4 else tmp7259)
tmp7345 = (tmp7346 if depth3 else tmp7307)
tmp7347 = (tmp7307 if depth3 else tmp7309)
tmp7344 = (tmp7345 if depth2 else tmp7347)
tmp7349 = (tmp7307 if depth3 else tmp7314)
tmp7348 = (tmp7307 if depth2 else tmp7349)
tmp7343 = (tmp7344 if depth1 else tmp7348)
tmp7353 = (tmp7042 if depth4 else tmp7267)
tmp7352 = (tmp7353 if depth3 else tmp7319)
tmp7351 = (tmp7352 if depth2 else tmp7319)
tmp7356 = (tmp7042 if depth4 else tmp7271)
tmp7355 = (tmp7356 if depth3 else tmp7319)
tmp7357 = (tmp7319 if depth3 else tmp7324)
tmp7354 = (tmp7355 if depth2 else tmp7357)
tmp7350 = (tmp7351 if depth1 else tmp7354)
tmp7342 = (tmp7343 if s0 else tmp7350)
tmp7326 = (tmp7327 if s1 else tmp7342)
tmp7274 = (tmp7275 if s2 else tmp7326)
tmp7364 = (tmp6952 if depth4 else tmp7281)
tmp7363 = (tmp7364 if depth3 else tmp7331)
tmp7366 = (tmp6952 if depth4 else tmp7284)
tmp7365 = (tmp7366 if depth3 else tmp7331)
tmp7362 = (tmp7363 if depth2 else tmp7365)
tmp7369 = (tmp6952 if depth4 else tmp7288)
tmp7368 = (tmp7369 if depth3 else tmp7331)
tmp7367 = (tmp7368 if depth2 else tmp7331)
tmp7361 = (tmp7362 if depth1 else tmp7367)
tmp7372 = (tmp6988 if depth3 else tmp7292)
tmp7374 = (tmp6988 if depth4 else tmp7295)
tmp7373 = (tmp7374 if depth3 else tmp7292)
tmp7371 = (tmp7372 if depth2 else tmp7373)
tmp7377 = (tmp6988 if depth4 else tmp7299)
tmp7376 = (tmp7377 if depth3 else tmp7292)
tmp7379 = (tmp6988 if depth4 else tmp7302)
tmp7378 = (tmp7379 if depth3 else tmp7292)
tmp7375 = (tmp7376 if depth2 else tmp7378)
tmp7370 = (tmp7371 if depth1 else tmp7375)
tmp7360 = (tmp7361 if s0 else tmp7370)
tmp7383 = (tmp7014 if depth3 else tmp7346)
tmp7385 = (tmp7014 if depth4 else tmp7310)
tmp7384 = (tmp7385 if depth3 else tmp7307)
tmp7382 = (tmp7383 if depth2 else tmp7384)
tmp7387 = (tmp7014 if depth3 else tmp7307)
tmp7389 = (tmp7014 if depth4 else tmp7315)
tmp7388 = (tmp7389 if depth3 else tmp7307)
tmp7386 = (tmp7387 if depth2 else tmp7388)
tmp7381 = (tmp7382 if depth1 else tmp7386)
tmp7392 = (tmp7042 if depth3 else tmp7353)
tmp7393 = (tmp7042 if depth3 else tmp7319)
tmp7391 = (tmp7392 if depth2 else tmp7393)
tmp7395 = (tmp7042 if depth3 else tmp7356)
tmp7397 = (tmp7042 if depth4 else tmp7325)
tmp7396 = (tmp7397 if depth3 else tmp7319)
tmp7394 = (tmp7395 if depth2 else tmp7396)
tmp7390 = (tmp7391 if depth1 else tmp7394)
tmp7380 = (tmp7381 if s0 else tmp7390)
tmp7359 = (tmp7360 if s1 else tmp7380)
tmp7402 = (tmp6952 if depth3 else tmp7364)
tmp7403 = (tmp6952 if depth3 else tmp7366)
tmp7401 = (tmp7402 if depth2 else tmp7403)
tmp7405 = (tmp6952 if depth3 else tmp7369)
tmp7406 = (tmp6952 if depth3 else tmp7331)
tmp7404 = (tmp7405 if depth2 else tmp7406)
tmp7400 = (tmp7401 if depth1 else tmp7404)
tmp7409 = (tmp6988 if depth3 else tmp7374)
tmp7408 = (tmp6988 if depth2 else tmp7409)
tmp7411 = (tmp6988 if depth3 else tmp7377)
tmp7412 = (tmp6988 if depth3 else tmp7379)
tmp7410 = (tmp7411 if depth2 else tmp7412)
tmp7407 = (tmp7408 if depth1 else tmp7410)
tmp7399 = (tmp7400 if s0 else tmp7407)
tmp7420 = (tmp7015 if depth7 else tmp7021)
tmp7419 = (tmp7420 if depth6 else tmp7014)
tmp7418 = (tmp7419 if depth5 else tmp7014)
tmp7417 = (tmp7418 if depth4 else tmp7014)
tmp7416 = (tmp7417 if depth3 else tmp7014)
tmp7421 = (tmp7014 if depth3 else tmp7385)
tmp7415 = (tmp7416 if depth2 else tmp7421)
tmp7423 = (tmp7014 if depth3 else tmp7389)
tmp7422 = (tmp7014 if depth2 else tmp7423)
tmp7414 = (tmp7415 if depth1 else tmp7422)
tmp7430 = (tmp6958 if depth7 else tmp6967)
tmp7429 = (tmp7430 if depth6 else tmp7042)
tmp7428 = (tmp7429 if depth5 else tmp7042)
tmp7427 = (tmp7428 if depth4 else tmp7042)
tmp7426 = (tmp7427 if depth3 else tmp7042)
tmp7425 = (tmp7426 if depth2 else tmp7042)
tmp7436 = (tmp6958 if depth7 else tmp7056)
tmp7435 = (tmp7436 if depth6 else tmp7042)
tmp7434 = (tmp7435 if depth5 else tmp7042)
tmp7433 = (tmp7434 if depth4 else tmp7042)
tmp7432 = (tmp7433 if depth3 else tmp7042)
tmp7437 = (tmp7042 if depth3 else tmp7397)
tmp7431 = (tmp7432 if depth2 else tmp7437)
tmp7424 = (tmp7425 if depth1 else tmp7431)
tmp7413 = (tmp7414 if s0 else tmp7424)
tmp7398 = (tmp7399 if s1 else tmp7413)
tmp7358 = (tmp7359 if s2 else tmp7398)
tmp7273 = (tmp7274 if s3 else tmp7358)
tmp7100 = (1 - (tmp7101 if s4 else tmp7273))
tmp6879 = (tmp6880 if s5 else tmp7100)
tmp7450 = (tmp6953 if depth7 else tmp6966)
tmp7449 = (tmp7450 if depth6 else tmp6952)
tmp7448 = (tmp7449 if depth5 else tmp6952)
tmp7447 = (tmp7448 if depth4 else tmp6952)
tmp7446 = (tmp7447 if depth3 else tmp6952)
tmp7455 = (tmp6953 if depth7 else tmp6975)
tmp7454 = (tmp7455 if depth6 else tmp6952)
tmp7453 = (tmp7454 if depth5 else tmp6952)
tmp7452 = (tmp7453 if depth4 else tmp6952)
tmp7451 = (tmp7452 if depth3 else tmp6952)
tmp7445 = (tmp7446 if depth2 else tmp7451)
tmp7461 = (tmp6953 if depth7 else tmp6983)
tmp7460 = (tmp7461 if depth6 else tmp6952)
tmp7459 = (tmp7460 if depth5 else tmp6952)
tmp7458 = (tmp7459 if depth4 else tmp6952)
tmp7457 = (tmp7458 if depth3 else tmp6952)
tmp7456 = (tmp7457 if depth2 else tmp6952)
tmp7444 = (tmp7445 if depth1 else tmp7456)
tmp7467 = (tmp6954 if depth6 else tmp6988)
tmp7466 = (tmp7467 if depth5 else tmp6988)
tmp7465 = (tmp7466 if depth4 else tmp6988)
tmp7464 = (tmp7465 if depth3 else tmp6988)
tmp7472 = (tmp6954 if depth7 else tmp6976)
tmp7471 = (tmp7472 if depth6 else tmp6988)
tmp7470 = (tmp7471 if depth5 else tmp6988)
tmp7469 = (tmp7470 if depth4 else tmp6988)
tmp7468 = (tmp7469 if depth3 else tmp6988)
tmp7463 = (tmp7464 if depth2 else tmp7468)
tmp7478 = (tmp6954 if depth7 else tmp7002)
tmp7477 = (tmp7478 if depth6 else tmp6988)
tmp7476 = (tmp7477 if depth5 else tmp6988)
tmp7475 = (tmp7476 if depth4 else tmp6988)
tmp7474 = (tmp7475 if depth3 else tmp6988)
tmp7483 = (tmp6954 if depth7 else tmp7008)
tmp7482 = (tmp7483 if depth6 else tmp6988)
tmp7481 = (tmp7482 if depth5 else tmp6988)
tmp7480 = (tmp7481 if depth4 else tmp6988)
tmp7479 = (tmp7480 if depth3 else tmp6988)
tmp7473 = (tmp7474 if depth2 else tmp7479)
tmp7462 = (tmp7463 if depth1 else tmp7473)
tmp7443 = (tmp7444 if s0 else tmp7462)
tmp7490 = (tmp7015 if depth6 else tmp7014)
tmp7489 = (tmp7490 if depth5 else tmp7014)
tmp7488 = (tmp7489 if depth4 else tmp7014)
tmp7487 = (tmp7488 if depth3 else tmp7417)
tmp7495 = (tmp7015 if depth7 else tmp7027)
tmp7494 = (tmp7495 if depth6 else tmp7014)
tmp7493 = (tmp7494 if depth5 else tmp7014)
tmp7492 = (tmp7493 if depth4 else tmp7014)
tmp7491 = (tmp7492 if depth3 else tmp7014)
tmp7486 = (tmp7487 if depth2 else tmp7491)
tmp7497 = (tmp7488 if depth3 else tmp7014)
tmp7502 = (tmp7015 if depth7 else tmp7037)
tmp7501 = (tmp7502 if depth6 else tmp7014)
tmp7500 = (tmp7501 if depth5 else tmp7014)
tmp7499 = (tmp7500 if depth4 else tmp7014)
tmp7498 = (tmp7499 if depth3 else tmp7014)
tmp7496 = (tmp7497 if depth2 else tmp7498)
tmp7485 = (tmp7486 if depth1 else tmp7496)
tmp7508 = (tmp6958 if depth6 else tmp7042)
tmp7507 = (tmp7508 if depth5 else tmp7042)
tmp7506 = (tmp7507 if depth4 else tmp7042)
tmp7505 = (tmp7506 if depth3 else tmp7427)
tmp7509 = (tmp7506 if depth3 else tmp7042)
tmp7504 = (tmp7505 if depth2 else tmp7509)
tmp7511 = (tmp7506 if depth3 else tmp7433)
tmp7516 = (tmp6958 if depth7 else tmp7062)
tmp7515 = (tmp7516 if depth6 else tmp7042)
tmp7514 = (tmp7515 if depth5 else tmp7042)
tmp7513 = (tmp7514 if depth4 else tmp7042)
tmp7512 = (tmp7513 if depth3 else tmp7042)
tmp7510 = (tmp7511 if depth2 else tmp7512)
tmp7503 = (tmp7504 if depth1 else tmp7510)
tmp7484 = (tmp7485 if s0 else tmp7503)
tmp7442 = (tmp7443 if s1 else tmp7484)
tmp7524 = (tmp6953 if depth6 else tmp6952)
tmp7523 = (tmp7524 if depth5 else tmp6952)
tmp7522 = (tmp7523 if depth4 else tmp6952)
tmp7521 = (tmp7522 if depth3 else tmp7447)
tmp7525 = (tmp7522 if depth3 else tmp7452)
tmp7520 = (tmp7521 if depth2 else tmp7525)
tmp7527 = (tmp7522 if depth3 else tmp7458)
tmp7528 = (tmp7522 if depth3 else tmp6952)
tmp7526 = (tmp7527 if depth2 else tmp7528)
tmp7519 = (tmp7520 if depth1 else tmp7526)
tmp7531 = (tmp7465 if depth3 else tmp7469)
tmp7530 = (tmp7465 if depth2 else tmp7531)
tmp7533 = (tmp7465 if depth3 else tmp7475)
tmp7534 = (tmp7465 if depth3 else tmp7480)
tmp7532 = (tmp7533 if depth2 else tmp7534)
tmp7529 = (tmp7530 if depth1 else tmp7532)
tmp7518 = (tmp7519 if s0 else tmp7529)
tmp7539 = (tmp7489 if depth4 else tmp7418)
tmp7538 = (tmp7539 if depth3 else tmp7488)
tmp7540 = (tmp7488 if depth3 else tmp7492)
tmp7537 = (tmp7538 if depth2 else tmp7540)
tmp7542 = (tmp7488 if depth3 else tmp7499)
tmp7541 = (tmp7488 if depth2 else tmp7542)
tmp7536 = (tmp7537 if depth1 else tmp7541)
tmp7546 = (tmp7507 if depth4 else tmp7428)
tmp7545 = (tmp7546 if depth3 else tmp7506)
tmp7544 = (tmp7545 if depth2 else tmp7506)
tmp7549 = (tmp7507 if depth4 else tmp7434)
tmp7548 = (tmp7549 if depth3 else tmp7506)
tmp7550 = (tmp7506 if depth3 else tmp7513)
tmp7547 = (tmp7548 if depth2 else tmp7550)
tmp7543 = (tmp7544 if depth1 else tmp7547)
tmp7535 = (tmp7536 if s0 else tmp7543)
tmp7517 = (tmp7518 if s1 else tmp7535)
tmp7441 = (tmp7442 if s2 else tmp7517)
tmp7557 = (tmp7523 if depth4 else tmp7448)
tmp7556 = (tmp7557 if depth3 else tmp7522)
tmp7559 = (tmp7523 if depth4 else tmp7453)
tmp7558 = (tmp7559 if depth3 else tmp7522)
tmp7555 = (tmp7556 if depth2 else tmp7558)
tmp7562 = (tmp7523 if depth4 else tmp7459)
tmp7561 = (tmp7562 if depth3 else tmp7522)
tmp7560 = (tmp7561 if depth2 else tmp7522)
tmp7554 = (tmp7555 if depth1 else tmp7560)
tmp7565 = (tmp7466 if depth3 else tmp7465)
tmp7567 = (tmp7466 if depth4 else tmp7470)
tmp7566 = (tmp7567 if depth3 else tmp7465)
tmp7564 = (tmp7565 if depth2 else tmp7566)
tmp7570 = (tmp7466 if depth4 else tmp7476)
tmp7569 = (tmp7570 if depth3 else tmp7465)
tmp7572 = (tmp7466 if depth4 else tmp7481)
tmp7571 = (tmp7572 if depth3 else tmp7465)
tmp7568 = (tmp7569 if depth2 else tmp7571)
tmp7563 = (tmp7564 if depth1 else tmp7568)
tmp7553 = (tmp7554 if s0 else tmp7563)
tmp7576 = (tmp7489 if depth3 else tmp7539)
tmp7578 = (tmp7489 if depth4 else tmp7493)
tmp7577 = (tmp7578 if depth3 else tmp7488)
tmp7575 = (tmp7576 if depth2 else tmp7577)
tmp7580 = (tmp7489 if depth3 else tmp7488)
tmp7582 = (tmp7489 if depth4 else tmp7500)
tmp7581 = (tmp7582 if depth3 else tmp7488)
tmp7579 = (tmp7580 if depth2 else tmp7581)
tmp7574 = (tmp7575 if depth1 else tmp7579)
tmp7585 = (tmp7507 if depth3 else tmp7546)
tmp7586 = (tmp7507 if depth3 else tmp7506)
tmp7584 = (tmp7585 if depth2 else tmp7586)
tmp7588 = (tmp7507 if depth3 else tmp7549)
tmp7590 = (tmp7507 if depth4 else tmp7514)
tmp7589 = (tmp7590 if depth3 else tmp7506)
tmp7587 = (tmp7588 if depth2 else tmp7589)
tmp7583 = (tmp7584 if depth1 else tmp7587)
tmp7573 = (tmp7574 if s0 else tmp7583)
tmp7552 = (tmp7553 if s1 else tmp7573)
tmp7595 = (tmp7523 if depth3 else tmp7557)
tmp7596 = (tmp7523 if depth3 else tmp7559)
tmp7594 = (tmp7595 if depth2 else tmp7596)
tmp7598 = (tmp7523 if depth3 else tmp7562)
tmp7599 = (tmp7523 if depth3 else tmp7522)
tmp7597 = (tmp7598 if depth2 else tmp7599)
tmp7593 = (tmp7594 if depth1 else tmp7597)
tmp7602 = (tmp7466 if depth3 else tmp7567)
tmp7601 = (tmp7466 if depth2 else tmp7602)
tmp7604 = (tmp7466 if depth3 else tmp7570)
tmp7605 = (tmp7466 if depth3 else tmp7572)
tmp7603 = (tmp7604 if depth2 else tmp7605)
tmp7600 = (tmp7601 if depth1 else tmp7603)
tmp7592 = (tmp7593 if s0 else tmp7600)
tmp7611 = (tmp7490 if depth5 else tmp7419)
tmp7610 = (tmp7611 if depth4 else tmp7489)
tmp7609 = (tmp7610 if depth3 else tmp7489)
tmp7612 = (tmp7489 if depth3 else tmp7578)
tmp7608 = (tmp7609 if depth2 else tmp7612)
tmp7614 = (tmp7489 if depth3 else tmp7582)
tmp7613 = (tmp7489 if depth2 else tmp7614)
tmp7607 = (tmp7608 if depth1 else tmp7613)
tmp7619 = (tmp7508 if depth5 else tmp7429)
tmp7618 = (tmp7619 if depth4 else tmp7507)
tmp7617 = (tmp7618 if depth3 else tmp7507)
tmp7616 = (tmp7617 if depth2 else tmp7507)
tmp7623 = (tmp7508 if depth5 else tmp7435)
tmp7622 = (tmp7623 if depth4 else tmp7507)
tmp7621 = (tmp7622 if depth3 else tmp7507)
tmp7624 = (tmp7507 if depth3 else tmp7590)
tmp7620 = (tmp7621 if depth2 else tmp7624)
tmp7615 = (tmp7616 if depth1 else tmp7620)
tmp7606 = (tmp7607 if s0 else tmp7615)
tmp7591 = (tmp7592 if s1 else tmp7606)
tmp7551 = (tmp7552 if s2 else tmp7591)
tmp7440 = (tmp7441 if s3 else tmp7551)
tmp7633 = (tmp7524 if depth5 else tmp7449)
tmp7632 = (tmp7633 if depth4 else tmp7523)
tmp7631 = (tmp7632 if depth3 else tmp7523)
tmp7636 = (tmp7524 if depth5 else tmp7454)
tmp7635 = (tmp7636 if depth4 else tmp7523)
tmp7634 = (tmp7635 if depth3 else tmp7523)
tmp7630 = (tmp7631 if depth2 else tmp7634)
tmp7640 = (tmp7524 if depth5 else tmp7460)
tmp7639 = (tmp7640 if depth4 else tmp7523)
tmp7638 = (tmp7639 if depth3 else tmp7523)
tmp7637 = (tmp7638 if depth2 else tmp7523)
tmp7629 = (tmp7630 if depth1 else tmp7637)
tmp7644 = (tmp7467 if depth4 else tmp7466)
tmp7643 = (tmp7644 if depth3 else tmp7466)
tmp7647 = (tmp7467 if depth5 else tmp7471)
tmp7646 = (tmp7647 if depth4 else tmp7466)
tmp7645 = (tmp7646 if depth3 else tmp7466)
tmp7642 = (tmp7643 if depth2 else tmp7645)
tmp7651 = (tmp7467 if depth5 else tmp7477)
tmp7650 = (tmp7651 if depth4 else tmp7466)
tmp7649 = (tmp7650 if depth3 else tmp7466)
tmp7654 = (tmp7467 if depth5 else tmp7482)
tmp7653 = (tmp7654 if depth4 else tmp7466)
tmp7652 = (tmp7653 if depth3 else tmp7466)
tmp7648 = (tmp7649 if depth2 else tmp7652)
tmp7641 = (tmp7642 if depth1 else tmp7648)
tmp7628 = (tmp7629 if s0 else tmp7641)
tmp7659 = (tmp7490 if depth4 else tmp7489)
tmp7658 = (tmp7659 if depth3 else tmp7610)
tmp7662 = (tmp7490 if depth5 else tmp7494)
tmp7661 = (tmp7662 if depth4 else tmp7489)
tmp7660 = (tmp7661 if depth3 else tmp7489)
tmp7657 = (tmp7658 if depth2 else tmp7660)
tmp7664 = (tmp7659 if depth3 else tmp7489)
tmp7667 = (tmp7490 if depth5 else tmp7501)
tmp7666 = (tmp7667 if depth4 else tmp7489)
tmp7665 = (tmp7666 if depth3 else tmp7489)
tmp7663 = (tmp7664 if depth2 else tmp7665)
tmp7656 = (tmp7657 if depth1 else tmp7663)
tmp7671 = (tmp7508 if depth4 else tmp7507)
tmp7670 = (tmp7671 if depth3 else tmp7618)
tmp7672 = (tmp7671 if depth3 else tmp7507)
tmp7669 = (tmp7670 if depth2 else tmp7672)
tmp7674 = (tmp7671 if depth3 else tmp7622)
tmp7677 = (tmp7508 if depth5 else tmp7515)
tmp7676 = (tmp7677 if depth4 else tmp7507)
tmp7675 = (tmp7676 if depth3 else tmp7507)
tmp7673 = (tmp7674 if depth2 else tmp7675)
tmp7668 = (tmp7669 if depth1 else tmp7673)
tmp7655 = (tmp7656 if s0 else tmp7668)
tmp7627 = (tmp7628 if s1 else tmp7655)
tmp7683 = (tmp7524 if depth4 else tmp7523)
tmp7682 = (tmp7683 if depth3 else tmp7632)
tmp7684 = (tmp7683 if depth3 else tmp7635)
tmp7681 = (tmp7682 if depth2 else tmp7684)
tmp7686 = (tmp7683 if depth3 else tmp7639)
tmp7687 = (tmp7683 if depth3 else tmp7523)
tmp7685 = (tmp7686 if depth2 else tmp7687)
tmp7680 = (tmp7681 if depth1 else tmp7685)
tmp7690 = (tmp7644 if depth3 else tmp7646)
tmp7689 = (tmp7644 if depth2 else tmp7690)
tmp7692 = (tmp7644 if depth3 else tmp7650)
tmp7693 = (tmp7644 if depth3 else tmp7653)
tmp7691 = (tmp7692 if depth2 else tmp7693)
tmp7688 = (tmp7689 if depth1 else tmp7691)
tmp7679 = (tmp7680 if s0 else tmp7688)
tmp7698 = (tmp7490 if depth4 else tmp7611)
tmp7697 = (tmp7698 if depth3 else tmp7659)
tmp7699 = (tmp7659 if depth3 else tmp7661)
tmp7696 = (tmp7697 if depth2 else tmp7699)
tmp7701 = (tmp7659 if depth3 else tmp7666)
tmp7700 = (tmp7659 if depth2 else tmp7701)
tmp7695 = (tmp7696 if depth1 else tmp7700)
tmp7705 = (tmp7508 if depth4 else tmp7619)
tmp7704 = (tmp7705 if depth3 else tmp7671)
tmp7703 = (tmp7704 if depth2 else tmp7671)
tmp7708 = (tmp7508 if depth4 else tmp7623)
tmp7707 = (tmp7708 if depth3 else tmp7671)
tmp7709 = (tmp7671 if depth3 else tmp7676)
tmp7706 = (tmp7707 if depth2 else tmp7709)
tmp7702 = (tmp7703 if depth1 else tmp7706)
tmp7694 = (tmp7695 if s0 else tmp7702)
tmp7678 = (tmp7679 if s1 else tmp7694)
tmp7626 = (tmp7627 if s2 else tmp7678)
tmp7716 = (tmp7524 if depth4 else tmp7633)
tmp7715 = (tmp7716 if depth3 else tmp7683)
tmp7718 = (tmp7524 if depth4 else tmp7636)
tmp7717 = (tmp7718 if depth3 else tmp7683)
tmp7714 = (tmp7715 if depth2 else tmp7717)
tmp7721 = (tmp7524 if depth4 else tmp7640)
tmp7720 = (tmp7721 if depth3 else tmp7683)
tmp7719 = (tmp7720 if depth2 else tmp7683)
tmp7713 = (tmp7714 if depth1 else tmp7719)
tmp7724 = (tmp7467 if depth3 else tmp7644)
tmp7726 = (tmp7467 if depth4 else tmp7647)
tmp7725 = (tmp7726 if depth3 else tmp7644)
tmp7723 = (tmp7724 if depth2 else tmp7725)
tmp7729 = (tmp7467 if depth4 else tmp7651)
tmp7728 = (tmp7729 if depth3 else tmp7644)
tmp7731 = (tmp7467 if depth4 else tmp7654)
tmp7730 = (tmp7731 if depth3 else tmp7644)
tmp7727 = (tmp7728 if depth2 else tmp7730)
tmp7722 = (tmp7723 if depth1 else tmp7727)
tmp7712 = (tmp7713 if s0 else tmp7722)
tmp7735 = (tmp7490 if depth3 else tmp7698)
tmp7737 = (tmp7490 if depth4 else tmp7662)
tmp7736 = (tmp7737 if depth3 else tmp7659)
tmp7734 = (tmp7735 if depth2 else tmp7736)
tmp7739 = (tmp7490 if depth3 else tmp7659)
tmp7741 = (tmp7490 if depth4 else tmp7667)
tmp7740 = (tmp7741 if depth3 else tmp7659)
tmp7738 = (tmp7739 if depth2 else tmp7740)
tmp7733 = (tmp7734 if depth1 else tmp7738)
tmp7744 = (tmp7508 if depth3 else tmp7705)
tmp7745 = (tmp7508 if depth3 else tmp7671)
tmp7743 = (tmp7744 if depth2 else tmp7745)
tmp7747 = (tmp7508 if depth3 else tmp7708)
tmp7749 = (tmp7508 if depth4 else tmp7677)
tmp7748 = (tmp7749 if depth3 else tmp7671)
tmp7746 = (tmp7747 if depth2 else tmp7748)
tmp7742 = (tmp7743 if depth1 else tmp7746)
tmp7732 = (tmp7733 if s0 else tmp7742)
tmp7711 = (tmp7712 if s1 else tmp7732)
tmp7754 = (tmp7524 if depth3 else tmp7716)
tmp7755 = (tmp7524 if depth3 else tmp7718)
tmp7753 = (tmp7754 if depth2 else tmp7755)
tmp7757 = (tmp7524 if depth3 else tmp7721)
tmp7758 = (tmp7524 if depth3 else tmp7683)
tmp7756 = (tmp7757 if depth2 else tmp7758)
tmp7752 = (tmp7753 if depth1 else tmp7756)
tmp7761 = (tmp7467 if depth3 else tmp7726)
tmp7760 = (tmp7467 if depth2 else tmp7761)
tmp7763 = (tmp7467 if depth3 else tmp7729)
tmp7764 = (tmp7467 if depth3 else tmp7731)
tmp7762 = (tmp7763 if depth2 else tmp7764)
tmp7759 = (tmp7760 if depth1 else tmp7762)
tmp7751 = (tmp7752 if s0 else tmp7759)
tmp7771 = (tmp7015 if depth6 else tmp7420)
tmp7770 = (tmp7771 if depth5 else tmp7490)
tmp7769 = (tmp7770 if depth4 else tmp7490)
tmp7768 = (tmp7769 if depth3 else tmp7490)
tmp7772 = (tmp7490 if depth3 else tmp7737)
tmp7767 = (tmp7768 if depth2 else tmp7772)
tmp7774 = (tmp7490 if depth3 else tmp7741)
tmp7773 = (tmp7490 if depth2 else tmp7774)
tmp7766 = (tmp7767 if depth1 else tmp7773)
tmp7780 = (tmp6958 if depth6 else tmp7430)
tmp7779 = (tmp7780 if depth5 else tmp7508)
tmp7778 = (tmp7779 if depth4 else tmp7508)
tmp7777 = (tmp7778 if depth3 else tmp7508)
tmp7776 = (tmp7777 if depth2 else tmp7508)
tmp7785 = (tmp6958 if depth6 else tmp7436)
tmp7784 = (tmp7785 if depth5 else tmp7508)
tmp7783 = (tmp7784 if depth4 else tmp7508)
tmp7782 = (tmp7783 if depth3 else tmp7508)
tmp7786 = (tmp7508 if depth3 else tmp7749)
tmp7781 = (tmp7782 if depth2 else tmp7786)
tmp7775 = (tmp7776 if depth1 else tmp7781)
tmp7765 = (tmp7766 if s0 else tmp7775)
tmp7750 = (tmp7751 if s1 else tmp7765)
tmp7710 = (tmp7711 if s2 else tmp7750)
tmp7625 = (tmp7626 if s3 else tmp7710)
tmp7439 = (tmp7440 if s4 else tmp7625)
tmp7797 = (tmp6953 if depth6 else tmp7450)
tmp7796 = (tmp7797 if depth5 else tmp7524)
tmp7795 = (tmp7796 if depth4 else tmp7524)
tmp7794 = (tmp7795 if depth3 else tmp7524)
tmp7801 = (tmp6953 if depth6 else tmp7455)
tmp7800 = (tmp7801 if depth5 else tmp7524)
tmp7799 = (tmp7800 if depth4 else tmp7524)
tmp7798 = (tmp7799 if depth3 else tmp7524)
tmp7793 = (tmp7794 if depth2 else tmp7798)
tmp7806 = (tmp6953 if depth6 else tmp7461)
tmp7805 = (tmp7806 if depth5 else tmp7524)
tmp7804 = (tmp7805 if depth4 else tmp7524)
tmp7803 = (tmp7804 if depth3 else tmp7524)
tmp7802 = (tmp7803 if depth2 else tmp7524)
tmp7792 = (tmp7793 if depth1 else tmp7802)
tmp7811 = (tmp6954 if depth5 else tmp7467)
tmp7810 = (tmp7811 if depth4 else tmp7467)
tmp7809 = (tmp7810 if depth3 else tmp7467)
tmp7815 = (tmp6954 if depth6 else tmp7472)
tmp7814 = (tmp7815 if depth5 else tmp7467)
tmp7813 = (tmp7814 if depth4 else tmp7467)
tmp7812 = (tmp7813 if depth3 else tmp7467)
tmp7808 = (tmp7809 if depth2 else tmp7812)
tmp7820 = (tmp6954 if depth6 else tmp7478)
tmp7819 = (tmp7820 if depth5 else tmp7467)
tmp7818 = (tmp7819 if depth4 else tmp7467)
tmp7817 = (tmp7818 if depth3 else tmp7467)
tmp7824 = (tmp6954 if depth6 else tmp7483)
tmp7823 = (tmp7824 if depth5 else tmp7467)
tmp7822 = (tmp7823 if depth4 else tmp7467)
tmp7821 = (tmp7822 if depth3 else tmp7467)
tmp7816 = (tmp7817 if depth2 else tmp7821)
tmp7807 = (tmp7808 if depth1 else tmp7816)
tmp7791 = (tmp7792 if s0 else tmp7807)
tmp7830 = (tmp7015 if depth5 else tmp7490)
tmp7829 = (tmp7830 if depth4 else tmp7490)
tmp7828 = (tmp7829 if depth3 else tmp7769)
tmp7834 = (tmp7015 if depth6 else tmp7495)
tmp7833 = (tmp7834 if depth5 else tmp7490)
tmp7832 = (tmp7833 if depth4 else tmp7490)
tmp7831 = (tmp7832 if depth3 else tmp7490)
tmp7827 = (tmp7828 if depth2 else tmp7831)
tmp7836 = (tmp7829 if depth3 else tmp7490)
tmp7840 = (tmp7015 if depth6 else tmp7502)
tmp7839 = (tmp7840 if depth5 else tmp7490)
tmp7838 = (tmp7839 if depth4 else tmp7490)
tmp7837 = (tmp7838 if depth3 else tmp7490)
tmp7835 = (tmp7836 if depth2 else tmp7837)
tmp7826 = (tmp7827 if depth1 else tmp7835)
tmp7845 = (tmp6958 if depth5 else tmp7508)
tmp7844 = (tmp7845 if depth4 else tmp7508)
tmp7843 = (tmp7844 if depth3 else tmp7778)
tmp7846 = (tmp7844 if depth3 else tmp7508)
tmp7842 = (tmp7843 if depth2 else tmp7846)
tmp7848 = (tmp7844 if depth3 else tmp7783)
tmp7852 = (tmp6958 if depth6 else tmp7516)
tmp7851 = (tmp7852 if depth5 else tmp7508)
tmp7850 = (tmp7851 if depth4 else tmp7508)
tmp7849 = (tmp7850 if depth3 else tmp7508)
tmp7847 = (tmp7848 if depth2 else tmp7849)
tmp7841 = (tmp7842 if depth1 else tmp7847)
tmp7825 = (tmp7826 if s0 else tmp7841)
tmp7790 = (tmp7791 if s1 else tmp7825)
tmp7859 = (tmp6953 if depth5 else tmp7524)
tmp7858 = (tmp7859 if depth4 else tmp7524)
tmp7857 = (tmp7858 if depth3 else tmp7795)
tmp7860 = (tmp7858 if depth3 else tmp7799)
tmp7856 = (tmp7857 if depth2 else tmp7860)
tmp7862 = (tmp7858 if depth3 else tmp7804)
tmp7863 = (tmp7858 if depth3 else tmp7524)
tmp7861 = (tmp7862 if depth2 else tmp7863)
tmp7855 = (tmp7856 if depth1 else tmp7861)
tmp7866 = (tmp7810 if depth3 else tmp7813)
tmp7865 = (tmp7810 if depth2 else tmp7866)
tmp7868 = (tmp7810 if depth3 else tmp7818)
tmp7869 = (tmp7810 if depth3 else tmp7822)
tmp7867 = (tmp7868 if depth2 else tmp7869)
tmp7864 = (tmp7865 if depth1 else tmp7867)
tmp7854 = (tmp7855 if s0 else tmp7864)
tmp7874 = (tmp7830 if depth4 else tmp7770)
tmp7873 = (tmp7874 if depth3 else tmp7829)
tmp7875 = (tmp7829 if depth3 else tmp7832)
tmp7872 = (tmp7873 if depth2 else tmp7875)
tmp7877 = (tmp7829 if depth3 else tmp7838)
tmp7876 = (tmp7829 if depth2 else tmp7877)
tmp7871 = (tmp7872 if depth1 else tmp7876)
tmp7881 = (tmp7845 if depth4 else tmp7779)
tmp7880 = (tmp7881 if depth3 else tmp7844)
tmp7879 = (tmp7880 if depth2 else tmp7844)
tmp7884 = (tmp7845 if depth4 else tmp7784)
tmp7883 = (tmp7884 if depth3 else tmp7844)
tmp7885 = (tmp7844 if depth3 else tmp7850)
tmp7882 = (tmp7883 if depth2 else tmp7885)
tmp7878 = (tmp7879 if depth1 else tmp7882)
tmp7870 = (tmp7871 if s0 else tmp7878)
tmp7853 = (tmp7854 if s1 else tmp7870)
tmp7789 = (tmp7790 if s2 else tmp7853)
tmp7892 = (tmp7859 if depth4 else tmp7796)
tmp7891 = (tmp7892 if depth3 else tmp7858)
tmp7894 = (tmp7859 if depth4 else tmp7800)
tmp7893 = (tmp7894 if depth3 else tmp7858)
tmp7890 = (tmp7891 if depth2 else tmp7893)
tmp7897 = (tmp7859 if depth4 else tmp7805)
tmp7896 = (tmp7897 if depth3 else tmp7858)
tmp7895 = (tmp7896 if depth2 else tmp7858)
tmp7889 = (tmp7890 if depth1 else tmp7895)
tmp7900 = (tmp7811 if depth3 else tmp7810)
tmp7902 = (tmp7811 if depth4 else tmp7814)
tmp7901 = (tmp7902 if depth3 else tmp7810)
tmp7899 = (tmp7900 if depth2 else tmp7901)
tmp7905 = (tmp7811 if depth4 else tmp7819)
tmp7904 = (tmp7905 if depth3 else tmp7810)
tmp7907 = (tmp7811 if depth4 else tmp7823)
tmp7906 = (tmp7907 if depth3 else tmp7810)
tmp7903 = (tmp7904 if depth2 else tmp7906)
tmp7898 = (tmp7899 if depth1 else tmp7903)
tmp7888 = (tmp7889 if s0 else tmp7898)
tmp7911 = (tmp7830 if depth3 else tmp7874)
tmp7913 = (tmp7830 if depth4 else tmp7833)
tmp7912 = (tmp7913 if depth3 else tmp7829)
tmp7910 = (tmp7911 if depth2 else tmp7912)
tmp7915 = (tmp7830 if depth3 else tmp7829)
tmp7917 = (tmp7830 if depth4 else tmp7839)
tmp7916 = (tmp7917 if depth3 else tmp7829)
tmp7914 = (tmp7915 if depth2 else tmp7916)
tmp7909 = (tmp7910 if depth1 else tmp7914)
tmp7920 = (tmp7845 if depth3 else tmp7881)
tmp7921 = (tmp7845 if depth3 else tmp7844)
tmp7919 = (tmp7920 if depth2 else tmp7921)
tmp7923 = (tmp7845 if depth3 else tmp7884)
tmp7925 = (tmp7845 if depth4 else tmp7851)
tmp7924 = (tmp7925 if depth3 else tmp7844)
tmp7922 = (tmp7923 if depth2 else tmp7924)
tmp7918 = (tmp7919 if depth1 else tmp7922)
tmp7908 = (tmp7909 if s0 else tmp7918)
tmp7887 = (tmp7888 if s1 else tmp7908)
tmp7930 = (tmp7859 if depth3 else tmp7892)
tmp7931 = (tmp7859 if depth3 else tmp7894)
tmp7929 = (tmp7930 if depth2 else tmp7931)
tmp7933 = (tmp7859 if depth3 else tmp7897)
tmp7934 = (tmp7859 if depth3 else tmp7858)
tmp7932 = (tmp7933 if depth2 else tmp7934)
tmp7928 = (tmp7929 if depth1 else tmp7932)
tmp7937 = (tmp7811 if depth3 else tmp7902)
tmp7936 = (tmp7811 if depth2 else tmp7937)
tmp7939 = (tmp7811 if depth3 else tmp7905)
tmp7940 = (tmp7811 if depth3 else tmp7907)
tmp7938 = (tmp7939 if depth2 else tmp7940)
tmp7935 = (tmp7936 if depth1 else tmp7938)
tmp7927 = (tmp7928 if s0 else tmp7935)
tmp7946 = (tmp7015 if depth5 else tmp7771)
tmp7945 = (tmp7946 if depth4 else tmp7830)
tmp7944 = (tmp7945 if depth3 else tmp7830)
tmp7947 = (tmp7830 if depth3 else tmp7913)
tmp7943 = (tmp7944 if depth2 else tmp7947)
tmp7949 = (tmp7830 if depth3 else tmp7917)
tmp7948 = (tmp7830 if depth2 else tmp7949)
tmp7942 = (tmp7943 if depth1 else tmp7948)
tmp7954 = (tmp6958 if depth5 else tmp7780)
tmp7953 = (tmp7954 if depth4 else tmp7845)
tmp7952 = (tmp7953 if depth3 else tmp7845)
tmp7951 = (tmp7952 if depth2 else tmp7845)
tmp7958 = (tmp6958 if depth5 else tmp7785)
tmp7957 = (tmp7958 if depth4 else tmp7845)
tmp7956 = (tmp7957 if depth3 else tmp7845)
tmp7959 = (tmp7845 if depth3 else tmp7925)
tmp7955 = (tmp7956 if depth2 else tmp7959)
tmp7950 = (tmp7951 if depth1 else tmp7955)
tmp7941 = (tmp7942 if s0 else tmp7950)
tmp7926 = (tmp7927 if s1 else tmp7941)
tmp7886 = (tmp7887 if s2 else tmp7926)
tmp7788 = (tmp7789 if s3 else tmp7886)
tmp7968 = (tmp6953 if depth5 else tmp7797)
tmp7967 = (tmp7968 if depth4 else tmp7859)
tmp7966 = (tmp7967 if depth3 else tmp7859)
tmp7971 = (tmp6953 if depth5 else tmp7801)
tmp7970 = (tmp7971 if depth4 else tmp7859)
tmp7969 = (tmp7970 if depth3 else tmp7859)
tmp7965 = (tmp7966 if depth2 else tmp7969)
tmp7975 = (tmp6953 if depth5 else tmp7806)
tmp7974 = (tmp7975 if depth4 else tmp7859)
tmp7973 = (tmp7974 if depth3 else tmp7859)
tmp7972 = (tmp7973 if depth2 else tmp7859)
tmp7964 = (tmp7965 if depth1 else tmp7972)
tmp7979 = (tmp6954 if depth4 else tmp7811)
tmp7978 = (tmp7979 if depth3 else tmp7811)
tmp7982 = (tmp6954 if depth5 else tmp7815)
tmp7981 = (tmp7982 if depth4 else tmp7811)
tmp7980 = (tmp7981 if depth3 else tmp7811)
tmp7977 = (tmp7978 if depth2 else tmp7980)
tmp7986 = (tmp6954 if depth5 else tmp7820)
tmp7985 = (tmp7986 if depth4 else tmp7811)
tmp7984 = (tmp7985 if depth3 else tmp7811)
tmp7989 = (tmp6954 if depth5 else tmp7824)
tmp7988 = (tmp7989 if depth4 else tmp7811)
tmp7987 = (tmp7988 if depth3 else tmp7811)
tmp7983 = (tmp7984 if depth2 else tmp7987)
tmp7976 = (tmp7977 if depth1 else tmp7983)
tmp7963 = (tmp7964 if s0 else tmp7976)
tmp7994 = (tmp7015 if depth4 else tmp7830)
tmp7993 = (tmp7994 if depth3 else tmp7945)
tmp7997 = (tmp7015 if depth5 else tmp7834)
tmp7996 = (tmp7997 if depth4 else tmp7830)
tmp7995 = (tmp7996 if depth3 else tmp7830)
tmp7992 = (tmp7993 if depth2 else tmp7995)
tmp7999 = (tmp7994 if depth3 else tmp7830)
tmp8002 = (tmp7015 if depth5 else tmp7840)
tmp8001 = (tmp8002 if depth4 else tmp7830)
tmp8000 = (tmp8001 if depth3 else tmp7830)
tmp7998 = (tmp7999 if depth2 else tmp8000)
tmp7991 = (tmp7992 if depth1 else tmp7998)
tmp8006 = (tmp6958 if depth4 else tmp7845)
tmp8005 = (tmp8006 if depth3 else tmp7953)
tmp8007 = (tmp8006 if depth3 else tmp7845)
tmp8004 = (tmp8005 if depth2 else tmp8007)
tmp8009 = (tmp8006 if depth3 else tmp7957)
tmp8012 = (tmp6958 if depth5 else tmp7852)
tmp8011 = (tmp8012 if depth4 else tmp7845)
tmp8010 = (tmp8011 if depth3 else tmp7845)
tmp8008 = (tmp8009 if depth2 else tmp8010)
tmp8003 = (tmp8004 if depth1 else tmp8008)
tmp7990 = (tmp7991 if s0 else tmp8003)
tmp7962 = (tmp7963 if s1 else tmp7990)
tmp8018 = (tmp6953 if depth4 else tmp7859)
tmp8017 = (tmp8018 if depth3 else tmp7967)
tmp8019 = (tmp8018 if depth3 else tmp7970)
tmp8016 = (tmp8017 if depth2 else tmp8019)
tmp8021 = (tmp8018 if depth3 else tmp7974)
tmp8022 = (tmp8018 if depth3 else tmp7859)
tmp8020 = (tmp8021 if depth2 else tmp8022)
tmp8015 = (tmp8016 if depth1 else tmp8020)
tmp8025 = (tmp7979 if depth3 else tmp7981)
tmp8024 = (tmp7979 if depth2 else tmp8025)
tmp8027 = (tmp7979 if depth3 else tmp7985)
tmp8028 = (tmp7979 if depth3 else tmp7988)
tmp8026 = (tmp8027 if depth2 else tmp8028)
tmp8023 = (tmp8024 if depth1 else tmp8026)
tmp8014 = (tmp8015 if s0 else tmp8023)
tmp8033 = (tmp7015 if depth4 else tmp7946)
tmp8032 = (tmp8033 if depth3 else tmp7994)
tmp8034 = (tmp7994 if depth3 else tmp7996)
tmp8031 = (tmp8032 if depth2 else tmp8034)
tmp8036 = (tmp7994 if depth3 else tmp8001)
tmp8035 = (tmp7994 if depth2 else tmp8036)
tmp8030 = (tmp8031 if depth1 else tmp8035)
tmp8040 = (tmp6958 if depth4 else tmp7954)
tmp8039 = (tmp8040 if depth3 else tmp8006)
tmp8038 = (tmp8039 if depth2 else tmp8006)
tmp8043 = (tmp6958 if depth4 else tmp7958)
tmp8042 = (tmp8043 if depth3 else tmp8006)
tmp8044 = (tmp8006 if depth3 else tmp8011)
tmp8041 = (tmp8042 if depth2 else tmp8044)
tmp8037 = (tmp8038 if depth1 else tmp8041)
tmp8029 = (tmp8030 if s0 else tmp8037)
tmp8013 = (tmp8014 if s1 else tmp8029)
tmp7961 = (tmp7962 if s2 else tmp8013)
tmp8051 = (tmp6953 if depth4 else tmp7968)
tmp8050 = (tmp8051 if depth3 else tmp8018)
tmp8053 = (tmp6953 if depth4 else tmp7971)
tmp8052 = (tmp8053 if depth3 else tmp8018)
tmp8049 = (tmp8050 if depth2 else tmp8052)
tmp8056 = (tmp6953 if depth4 else tmp7975)
tmp8055 = (tmp8056 if depth3 else tmp8018)
tmp8054 = (tmp8055 if depth2 else tmp8018)
tmp8048 = (tmp8049 if depth1 else tmp8054)
tmp8059 = (tmp6954 if depth3 else tmp7979)
tmp8061 = (tmp6954 if depth4 else tmp7982)
tmp8060 = (tmp8061 if depth3 else tmp7979)
tmp8058 = (tmp8059 if depth2 else tmp8060)
tmp8064 = (tmp6954 if depth4 else tmp7986)
tmp8063 = (tmp8064 if depth3 else tmp7979)
tmp8066 = (tmp6954 if depth4 else tmp7989)
tmp8065 = (tmp8066 if depth3 else tmp7979)
tmp8062 = (tmp8063 if depth2 else tmp8065)
tmp8057 = (tmp8058 if depth1 else tmp8062)
tmp8047 = (tmp8048 if s0 else tmp8057)
tmp8070 = (tmp7015 if depth3 else tmp8033)
tmp8072 = (tmp7015 if depth4 else tmp7997)
tmp8071 = (tmp8072 if depth3 else tmp7994)
tmp8069 = (tmp8070 if depth2 else tmp8071)
tmp8074 = (tmp7015 if depth3 else tmp7994)
tmp8076 = (tmp7015 if depth4 else tmp8002)
tmp8075 = (tmp8076 if depth3 else tmp7994)
tmp8073 = (tmp8074 if depth2 else tmp8075)
tmp8068 = (tmp8069 if depth1 else tmp8073)
tmp8079 = (tmp6958 if depth3 else tmp8040)
tmp8080 = (tmp6958 if depth3 else tmp8006)
tmp8078 = (tmp8079 if depth2 else tmp8080)
tmp8082 = (tmp6958 if depth3 else tmp8043)
tmp8084 = (tmp6958 if depth4 else tmp8012)
tmp8083 = (tmp8084 if depth3 else tmp8006)
tmp8081 = (tmp8082 if depth2 else tmp8083)
tmp8077 = (tmp8078 if depth1 else tmp8081)
tmp8067 = (tmp8068 if s0 else tmp8077)
tmp8046 = (tmp8047 if s1 else tmp8067)
tmp8090 = (tmp6957 if k1 else tmp6958)
tmp8095 = (tmp6957 if k1 else tmp6967)
tmp8094 = (tmp8090 if depth7 else tmp8095)
tmp8093 = (tmp8090 if depth6 else tmp8094)
tmp8092 = (tmp8090 if depth5 else tmp8093)
tmp8091 = (tmp8090 if depth4 else tmp8092)
tmp8089 = (tmp8090 if depth3 else tmp8091)
tmp8102 = (tmp6957 if k2 else tmp6895)
tmp8101 = (tmp8102 if k1 else tmp6962)
tmp8100 = (tmp8090 if depth7 else tmp8101)
tmp8099 = (tmp8090 if depth6 else tmp8100)
tmp8098 = (tmp8090 if depth5 else tmp8099)
tmp8097 = (tmp8090 if depth4 else tmp8098)
tmp8096 = (tmp8090 if depth3 else tmp8097)
tmp8088 = (tmp8089 if depth2 else tmp8096)
tmp8109 = (tmp8102 if k1 else tmp6967)
tmp8108 = (tmp8090 if depth7 else tmp8109)
tmp8107 = (tmp8090 if depth6 else tmp8108)
tmp8106 = (tmp8090 if depth5 else tmp8107)
tmp8105 = (tmp8090 if depth4 else tmp8106)
tmp8104 = (tmp8090 if depth3 else tmp8105)
tmp8115 = (tmp6895 if k1 else tmp6962)
tmp8114 = (tmp8090 if depth7 else tmp8115)
tmp8113 = (tmp8090 if depth6 else tmp8114)
tmp8112 = (tmp8090 if depth5 else tmp8113)
tmp8111 = (tmp8090 if depth4 else tmp8112)
tmp8110 = (tmp8090 if depth3 else tmp8111)
tmp8103 = (tmp8104 if depth2 else tmp8110)
tmp8087 = (tmp8088 if depth1 else tmp8103)
tmp8122 = (tmp6957 if depth7 else tmp8102)
tmp8121 = (tmp6957 if depth6 else tmp8122)
tmp8120 = (tmp6957 if depth5 else tmp8121)
tmp8119 = (tmp6957 if depth4 else tmp8120)
tmp8118 = (tmp6957 if depth3 else tmp8119)
tmp8117 = (tmp6957 if depth2 else tmp8118)
tmp8129 = (tmp6957 if k1 else tmp8102)
tmp8128 = (tmp6957 if depth7 else tmp8129)
tmp8127 = (tmp6957 if depth6 else tmp8128)
tmp8126 = (tmp6957 if depth5 else tmp8127)
tmp8125 = (tmp6957 if depth4 else tmp8126)
tmp8124 = (tmp6957 if depth3 else tmp8125)
tmp8135 = (tmp8102 if k1 else tmp6895)
tmp8134 = (tmp6957 if depth7 else tmp8135)
tmp8133 = (tmp6957 if depth6 else tmp8134)
tmp8132 = (tmp6957 if depth5 else tmp8133)
tmp8131 = (tmp6957 if depth4 else tmp8132)
tmp8130 = (tmp6957 if depth3 else tmp8131)
tmp8123 = (tmp8124 if depth2 else tmp8130)
tmp8116 = (tmp8117 if depth1 else tmp8123)
tmp8086 = (tmp8087 if s0 else tmp8116)
tmp8138 = (tmp6957 if depth2 else tmp8124)
tmp8137 = (tmp8138 if depth1 else tmp8117)
tmp8139 = (tmp6957 if depth1 else tmp8138)
tmp8136 = (tmp8137 if s0 else tmp8139)
tmp8085 = (tmp8086 if s1 else tmp8136)
tmp8045 = (tmp8046 if s2 else tmp8085)
tmp7960 = (tmp7961 if s3 else tmp8045)
tmp7787 = (tmp7788 if s4 else tmp7960)
tmp7438 = (1 - (tmp7439 if s5 else tmp7787))
tmp6878 = (tmp6879 if s6 else tmp7438)
tmp6863 = (1 - (tmp6864 if s7 else tmp6878))
s1n = tmp6863
tmp8146 = (1 - (1 if oxygen_low else 0))
tmp8145 = (1 if oxygen_full else tmp8146)
tmp8144 = (1 if k1 else tmp8145)
tmp8149 = (1 if oxygen_full else 0)
tmp8148 = (tmp8149 if k1 else 1)
tmp8150 = (1 if k1 else tmp8149)
tmp8147 = (tmp8148 if s0 else tmp8150)
tmp8143 = (tmp8144 if s1 else tmp8147)
tmp8142 = (tmp8143 if s4 else tmp8147)
tmp8141 = (tmp8142 if s6 else tmp8147)
tmp8159 = (1 if k2 else tmp8149)
tmp8158 = (tmp8159 if k1 else 1)
tmp8160 = (1 if k1 else tmp8159)
tmp8157 = (tmp8158 if s0 else tmp8160)
tmp8156 = (tmp8147 if s1 else tmp8157)
tmp8161 = (1 if s1 else tmp8144)
tmp8155 = (tmp8156 if s2 else tmp8161)
tmp8154 = (tmp8155 if s3 else tmp8147)
tmp8153 = (tmp8147 if s4 else tmp8154)
tmp8152 = (tmp8153 if s5 else tmp8147)
tmp8166 = (tmp8157 if s1 else 1)
tmp8165 = (tmp8147 if s2 else tmp8166)
tmp8164 = (tmp8147 if s3 else tmp8165)
tmp8163 = (tmp8147 if s4 else tmp8164)
tmp8162 = (tmp8147 if s5 else tmp8163)
tmp8151 = (tmp8152 if s6 else tmp8162)
tmp8140 = (1 - (tmp8141 if s7 else tmp8151))
s0n = tmp8140
self.s7 = s7n
self.s6 = s6n
self.s5 = s5n
self.s4 = s4n
self.s3 = s3n
self.s2 = s2n
self.s1 = s1n
self.s0 = s0n
return [ action4__s, action3__s, action2__s, action1__s, recovery__s]
|
1681102
|
from django.http import JsonResponse
from store.models import Product
from django.shortcuts import render, redirect
from cart.models import CartItem
from .forms import OrderForm
from .models import Order, OrderProduct, Payment
import datetime
from django.contrib import messages
import json
from django.template.loader import render_to_string
from django.core.mail import EmailMessage
def place_order(request, total=0, quantity=0):
current_user = request.user
cart_items = CartItem.objects.filter(user=current_user)
cart_count = cart_items.count()
if cart_count < 1:
return redirect('store')
grand_total = 0
tax = 0
total = 0
shipping_price = 20 # to be developped to calculate shipping price on distance basis
for item in cart_items:
if item.product.discount_price:
total += round(((item.product.discount_price) * item.quantity), 2)
quantity += item.quantity
else:
total += round(((item.product.price) * item.quantity), 2)
quantity += item.quantity
tax = round(((2 * total) / 100), 2)
grand_total = round((tax + total + shipping_price), 2)
if request.method == 'POST':
form = OrderForm(request.POST)
if form.is_valid():
data = Order()
data.user = current_user
data.f_name = form.cleaned_data['f_name']
data.l_name = form.cleaned_data['l_name']
data.email = form.cleaned_data['email']
data.tel = form.cleaned_data['tel']
data.address = form.cleaned_data['address']
data.country = form.cleaned_data['country']
data.state = form.cleaned_data['state']
data.city = form.cleaned_data['city']
data.zipcode = form.cleaned_data['zipcode']
data.order_note = form.cleaned_data['order_note']
data.order_total = grand_total
data.tax = tax
data.ip = request.META.get('REMOTE_ADDR')
if request.POST.get('terms', None) == None:
messages.error(request, 'You must accept terms & conditions! Please go back to cart and restart checkout process.')
return render(request, 'store/checkout.html')
else:
data.save()
year = int(datetime.date.today().strftime('%Y'))
month = int(datetime.date.today().strftime('%m'))
day = int(datetime.date.today().strftime('%d'))
d = datetime.date(year, month, day)
current_date = d.strftime("%Y%m%d")
order_number = current_date + str(data.id)
data.order_number = order_number
data.save()
order = Order.objects.get(user=current_user, is_ordered=False, order_number=order_number)
context = {
'order': order,
'cart_items': cart_items,
'total': total,
'tax': tax,
'shipping_price': shipping_price,
'grand_total': grand_total
}
return render(request, 'orders/payment.html', context)
else:
messages.error(request, 'Invalid inputs!')
return redirect('checkout')
def payment(request):
body = json.loads(request.body)
order = Order.objects.get(user=request.user, is_ordered=False, order_number=body['orderID'])
payment = Payment(
user = request.user,
payment_id = body['transactionID'],
payment_method = body['payment_method'],
amount_paid = order.order_total,
status = body['status'],
)
payment.save()
order.payment = payment
order.is_ordered = True
order.save()
cart_items = CartItem.objects.filter(user=request.user)
for item in cart_items:
orderproduct = OrderProduct()
orderproduct.order_id = order.id
orderproduct.payment = payment
orderproduct.user_id = request.user.id
orderproduct.product_id = item.product_id
orderproduct.quantity = item.quantity
orderproduct.product_price = item.product.price
orderproduct.ordered = True
orderproduct.save()
product = Product.objects.get(id=item.product_id)
product.stock -= item.quantity
product.save()
CartItem.objects.filter(user=request.user).delete()
subject = 'Account activation'
body = render_to_string('orders/order_received_email.html', {
'user': request.user,
'order': order,
})
to_email = request.user.email
send_email = EmailMessage(subject, body, to=[to_email])
data = {
'order_number': order.order_number,
'transactionID': payment.payment_id
}
return JsonResponse(data)
def order_completed(request):
order_number = request.GET.get('order_number')
transactionID = request.GET.get('payment_id')
payment = Payment.objects.get(payment_id=transactionID)
try:
order = Order.objects.get(order_number=order_number, is_ordered=True)
ordered_products = OrderProduct.objects.filter(order_id=order.id)
subtotal = 0
for prod in ordered_products:
subtotal += (prod.product_price * prod.quantity)
context = {
'order': order,
'ordered_products': ordered_products,
'ordder_number': order.order_number,
'transactionID': payment.payment_id,
'payment': payment,
'subtotal': subtotal,
}
return render(request, 'orders/order_completed.html', context)
except (Payment.DoesNotExist, Order.DoesNotExist):
return redirect('index')
|
1681103
|
import sys, os, glob, random
import time
import parser
import torch
import torch.nn as nn
# from AdaAdam import AdaAdam
import torch.optim as OPT
import numpy as np
from copy import deepcopy
from tqdm import tqdm, trange
import logging
from torchtext import data
import DataProcessing
from DataProcessing.MLTField import MTLField
from DataProcessing.NlcDatasetSingleFile import NlcDatasetSingleFile
from CNNModel import CNNModel
logger = logging.getLogger(__name__)
logging.basicConfig(format = '%(asctime)s - %(levelname)s - %(name)s - %(message)s',
datefmt = '%m/%d/%Y %H:%M:%S',
level = logging.INFO )
batch_size = 10
seed = 12345678
torch.manual_seed(seed)
Train = False
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
n_gpu = torch.cuda.device_count()
random.seed(seed)
np.random.seed(seed)
torch.manual_seed(seed)
if n_gpu > 0:
torch.cuda.manual_seed_all(seed)
def load_train_test_files(listfilename, test_suffix='.test'):
filein = open(listfilename, 'r')
file_tuples = []
task_classes = ['.t2', '.t4', '.t5']
for line in filein:
array = line.strip().split('\t')
line = array[0]
for t_class in task_classes:
trainfile = line + t_class + '.train'
devfile = line + t_class + '.dev'
testfile = line + t_class + test_suffix
file_tuples.append((trainfile, devfile, testfile))
filein.close()
return file_tuples
filelist = 'data/Amazon_few_shot/workspace.filtered.list'
targetlist = 'data/Amazon_few_shot/workspace.target.list'
workingdir = 'data/Amazon_few_shot'
emfilename = 'glove.6B.300d'
emfiledir = '..'
datasets = []
list_datasets = []
file_tuples = load_train_test_files(filelist)
print(file_tuples)
TEXT = MTLField(lower=True)
for (trainfile, devfile, testfile) in file_tuples:
print(trainfile, devfile, testfile)
LABEL1 = data.Field(sequential=False)
train1, dev1, test1 = NlcDatasetSingleFile.splits(
TEXT, LABEL1, path=workingdir, train=trainfile,
validation=devfile, test=testfile)
datasets.append((TEXT, LABEL1, train1, dev1, test1))
list_datasets.append(train1)
list_datasets.append(dev1)
list_datasets.append(test1)
target_datasets = []
target_file = load_train_test_files(targetlist)
print(target_file)
for (trainfile, devfile, testfile) in target_file:
print(trainfile, devfile, testfile)
LABEL2 = data.Field(sequential=False)
train2, dev2, test2 = NlcDatasetSingleFile.splits(TEXT, LABEL2, path=workingdir,
train=trainfile,validation=devfile, test=testfile)
target_datasets.append((TEXT, LABEL2, train2, dev2, test2))
datasets_iters = []
for (TEXT, LABEL, train, dev, test) in datasets:
train_iter, dev_iter, test_iter = data.BucketIterator.splits(
(train, dev, test), batch_size=batch_size, device=device,shuffle=True)
train_iter.repeat = False
datasets_iters.append((train_iter, dev_iter, test_iter))
fsl_ds_iters = []
for (TEXT, LABEL, train, dev, test) in target_datasets:
train_iter, dev_iter, test_iter = data.BucketIterator.splits(
(train,dev, test), batch_size=batch_size, device=device)
train_iter.repeat = False
fsl_ds_iters.append((train_iter, dev_iter, test_iter))
num_batch_total = 0
for i, (TEXT, LABEL, train, dev, test) in enumerate(datasets):
# print('DATASET%d'%(i+1))
# print('train.fields', train.fields)
# print('len(train)', len(train))
# print('len(dev)', len(dev))
# print('len(test)', len(test))
# print('vars(train[0])', vars(train[0]))
num_batch_total += len(train) / batch_size
TEXT.build_vocab(list_datasets, vectors = emfilename, vectors_cache = emfiledir)
# TEXT.build_vocab(list_dataset)
# build the vocabulary
for taskid, (TEXT, LABEL, train, dev, test) in enumerate(datasets):
LABEL.build_vocab(train, dev, test)
LABEL.vocab.itos = LABEL.vocab.itos[1:]
for k, v in LABEL.vocab.stoi.items():
LABEL.vocab.stoi[k] = v - 1
# print vocab information
# print('len(TEXT.vocab)', len(TEXT.vocab))
# print('TEXT.vocab.vectors.size()', TEXT.vocab.vectors.size())
# print(LABEL.vocab.itos)
# print(len(LABEL.vocab.itos))
# print(len(LABEL.vocab.stoi))
fsl_num_tasks = 0
for taskid, (TEXT, LABEL, train, dev, test) in enumerate(target_datasets):
fsl_num_tasks += 1
LABEL.build_vocab(train, dev, test)
LABEL.vocab.itos = LABEL.vocab.itos[1:]
for k, v in LABEL.vocab.stoi.items():
LABEL.vocab.stoi[k] = v - 1
nums_embed = len(TEXT.vocab)
dim_embed = 100
dim_w_hid = 200
dim_h_hid = 100
Inner_lr = 2e-6
Outer_lr = 1e-5
n_labels = []
for (TEXT, LABEL, train, dev, test) in datasets:
n_labels.append(len(LABEL.vocab))
print(n_labels)
num_tasks = len(n_labels)
print("num_tasks", num_tasks)
winsize = 3
num_labels = len(LABEL.vocab.itos)
model = CNNModel(nums_embed, num_labels, dim_embed, dim_w_hid, dim_h_hid, winsize, batch_size)
print("GPU Device: ", device)
model.to(device)
print(model)
criterion = nn.CrossEntropyLoss()
opt = OPT.Adam(model.parameters(), lr=Inner_lr)
Inner_epochs = 4
epochs = 2
N_task = 5
task_list = np.arange(num_tasks)
print("Total Batch: ", num_batch_total)
output_model_file = '/tmp/CNN_MAML_output'
if Train:
for t in trange(int(num_batch_total*epochs/Inner_epochs), desc="Iterations"):
selected_task = np.random.choice(task_list, N_task,replace=False)
weight_before = deepcopy(model.state_dict())
update_vars = []
fomaml_vars = []
for task_id in selected_task:
# print(task_id)
(train_iter, dev_iter, test_iter) = datasets_iters[task_id]
train_iter.init_epoch()
model.train()
n_correct = 0
n_step = 0
for inner_iter in range(Inner_epochs):
batch = next(iter(train_iter))
# print(batch.text)
# print(batch.label)
logits = model(batch.text)
loss = criterion(logits.view(-1, num_labels), batch.label.data.view(-1))
n_correct = (torch.max(logits, 1)[1].view(batch.label.size()).data == batch.label.data).sum()
n_step = batch.batch_size
loss.backward()
opt.step()
opt.zero_grad()
task_acc = 100.*n_correct/n_step
if t%10 == 0:
logger.info("Iter: %d, task id: %d, train acc: %f", t, task_id, task_acc)
weight_after = deepcopy(model.state_dict())
update_vars.append(weight_after)
model.load_state_dict(weight_before)
new_weight_dict = {}
for name in weight_before:
weight_list = [tmp_weight_dict[name] for tmp_weight_dict in update_vars]
weight_shape = list(weight_list[0].size())
stack_shape = [len(weight_list)] + weight_shape
stack_weight = torch.empty(stack_shape)
for i in range(len(weight_list)):
stack_weight[i,:] = weight_list[i]
new_weight_dict[name] = torch.mean(stack_weight, dim=0).cuda()
new_weight_dict[name] = weight_before[name]+(new_weight_dict[name]-weight_before[name])/Inner_lr*Outer_lr
model.load_state_dict(new_weight_dict)
torch.save(model.state_dict(), output_model_file)
model.load_state_dict(torch.load(output_model_file))
logger.info("***** Running evaluation *****")
fsl_task_list = np.arange(fsl_num_tasks)
weight_before = deepcopy(model.state_dict())
fsl_epochs = 3
Total_acc = 0
opt = OPT.Adam(model.parameters(), lr=3e-4)
for task_id in fsl_task_list:
model.train()
(train_iter, dev_iter, test_iter) = fsl_ds_iters[task_id]
train_iter.init_epoch()
batch = next(iter(train_iter))
for i in range(fsl_epochs):
logits = model(batch.text)
loss = criterion(logits.view(-1, num_labels), batch.label.data.view(-1))
n_correct = (torch.max(logits, 1)[1].view(batch.label.size()).data == batch.label.data).sum()
n_size = batch.batch_size
train_acc = 100. * n_correct / n_size
loss = criterion(logits.view(-1, num_labels), batch.label.data.view(-1))
loss.backward()
opt.step()
opt.zero_grad()
logger.info(" Task id: %d, fsl epoch: %d, Acc: %f, loss: %f", task_id, i, train_acc, loss)
model.eval()
test_iter.init_epoch()
n_correct = 0
n_size = 0
for test_batch_idx, test_batch in enumerate(test_iter):
with torch.no_grad():
logits = model(test_batch.text)
loss = criterion(logits.view(-1, num_labels), test_batch.label.data.view(-1))
n_correct += (torch.max(logits, 1)[1].view(test_batch.label.size()).data == test_batch.label.data).sum()
n_size += test_batch.batch_size
test_acc = 100.* n_correct/n_size
logger.info("FSL test Number: %d, Accuracy: %f",n_size, test_acc)
Total_acc += test_acc
model.load_state_dict(weight_before)
print("Mean Accuracy is : ", float(Total_acc)/fsl_num_tasks)
|
1681110
|
from django.db import models
from api.model.restaurant import Restaurant
from django.contrib.auth.models import User
class RestaurantRate(models.Model):
score = models.FloatField()
user = models.ForeignKey(User, on_delete=models.CASCADE)
restaurant = models.ForeignKey(Restaurant, on_delete=models.CASCADE)
class Meta:
unique_together = ('user', 'restaurant')
|
1681117
|
from django.test import TestCase
from .models import Resource
class TestResourceModels(TestCase):
"""Tests for Resource models."""
def setUp(self):
"""Sets up the model for testing"""
Resource.objects.create(
name='Forking',
link="https://www.youtube.com/watch?v=HbSjyU2vf6Y",
description="lorem ipsum")
Resource.objects.create(
name='The Git Story',
link="https://eventyret.github.io/the-git-story/",
description="lorem ipsum")
def test__str_method_returns_name(self):
"""Tests the string method on a resource."""
resource = Resource.objects.create(
name='The Git Story',
link="https://eventyret.github.io/the-git-story/",
description="lorem ipsum")
self.assertEqual(resource.__str__(), "The Git Story")
|
1681196
|
from multiprocessing import Pool
import time
import numpy as np
import torch
import gym
from lagom import Logger
from lagom import EpisodeRunner
from lagom.transform import describe
from lagom.utils import CloudpickleWrapper
from lagom.utils import pickle_dump
from lagom.utils import tensorify
from lagom.utils import set_global_seeds
from lagom.experiment import Config
from lagom.experiment import Grid
from lagom.experiment import run_experiment
from lagom.envs import TimeStepEnv
from lagom import CMAES
from baselines.cmaes.agent import Agent
config = Config(
{'log.freq': 10,
'checkpoint.num': 3,
'env.id': Grid(['Acrobot-v1', 'BipedalWalker-v2', 'Pendulum-v0', 'LunarLanderContinuous-v2']),
'nn.sizes': [64, 64],
# only for continuous control
'env.clip_action': True, # clip action within valid bound before step()
'agent.std0': 0.6, # initial std
'train.generations': 500, # total number of ES generations
'train.popsize': 32,
'train.worker_chunksize': 4, # must be divisible by popsize
'train.mu0': 0.0,
'train.std0': 1.0,
})
def make_env(config, seed, mode):
assert mode in ['train', 'eval']
env = gym.make(config['env.id'])
env.seed(seed)
env.observation_space.seed(seed)
env.action_space.seed(seed)
if config['env.clip_action'] and isinstance(env.action_space, gym.spaces.Box):
env = gym.wrappers.ClipAction(env) # TODO: use tanh to squash policy output when RescaleAction wrapper merged in gym
env = TimeStepEnv(env)
return env
def fitness(data):
torch.set_num_threads(1) # VERY IMPORTANT TO AVOID GETTING STUCK
config, seed, device, param = data
env = make_env(config, seed, 'train')
agent = Agent(config, env, device)
agent.from_vec(tensorify(param, 'cpu'))
runner = EpisodeRunner()
with torch.no_grad():
D = runner(agent, env, 10)
R = np.mean([sum(traj.rewards) for traj in D])
H = np.mean([traj.T for traj in D])
return R, H
def run(config, seed, device, logdir):
set_global_seeds(seed)
torch.set_num_threads(1) # VERY IMPORTANT TO AVOID GETTING STUCK
print('Initializing...')
agent = Agent(config, make_env(config, seed, 'eval'), device)
es = CMAES([config['train.mu0']]*agent.num_params, config['train.std0'],
{'popsize': config['train.popsize'],
'seed': seed})
train_logs = []
checkpoint_count = 0
with Pool(processes=config['train.popsize']//config['train.worker_chunksize']) as pool:
print('Finish initialization. Training starts...')
for generation in range(config['train.generations']):
t0 = time.perf_counter()
solutions = es.ask()
data = [(config, seed, device, solution) for solution in solutions]
out = pool.map(CloudpickleWrapper(fitness), data, chunksize=config['train.worker_chunksize'])
Rs, Hs = zip(*out)
es.tell(solutions, [-R for R in Rs])
logger = Logger()
logger('generation', generation+1)
logger('num_seconds', round(time.perf_counter() - t0, 1))
logger('Returns', describe(Rs, axis=-1, repr_indent=1, repr_prefix='\n'))
logger('Horizons', describe(Hs, axis=-1, repr_indent=1, repr_prefix='\n'))
logger('fbest', es.result.fbest)
train_logs.append(logger.logs)
if generation == 0 or (generation+1) % config['log.freq'] == 0:
logger.dump(keys=None, index=0, indent=0, border='-'*50)
if (generation+1) >= int(config['train.generations']*(checkpoint_count/(config['checkpoint.num'] - 1))):
agent.from_vec(tensorify(es.result.xbest, 'cpu'))
agent.checkpoint(logdir, generation+1)
checkpoint_count += 1
pickle_dump(obj=train_logs, f=logdir/'train_logs', ext='.pkl')
return None
if __name__ == '__main__':
run_experiment(run=run,
config=config,
seeds=[1770966829, 1500925526, 2054191100],
log_dir='logs/default',
max_workers=12, # tune to fulfill computation power
chunksize=1,
use_gpu=False,
gpu_ids=None)
|
1681226
|
import torch
from torch import nn
def _conv_block(in_channel, out_channel, kernel_size, stride, padding):
block = nn.Sequential(
nn.Conv2d(in_channel, out_channel, kernel_size=kernel_size, stride=stride, padding=padding),
nn.BatchNorm2d(out_channel),
nn.LeakyReLU(0.2, True) # TODO: check the negative slope?
)
return block
class ScaleAwareGen(nn.Module):
def __init__(self, in_channel=3, filter_count=32, kernel_size=3, stride=1, padding=1,
num_block_phi=5, num_block_psi=4, device='cpu'):
super().__init__()
self.in_channel = in_channel
self.filter_count = filter_count
self.kernel_size = kernel_size
self.stride = stride
self.padding = padding
# first network
self.num_block_phi = num_block_phi
# second network
self.num_block_psi = num_block_psi
# device
self.device = device
self.phi_network = self._phi_network()
self.psi_network = self._psi_network()
def forward(self, x, y_prev):
y = self.phi_network(x)
# TODO: check dimensions!
x_concat = torch.cat((x, y, y_prev), 1)
attention_map = self.psi_network(x_concat)
return attention_map * y + (1 - attention_map) * y_prev
def _phi_network(self):
phi_net = nn.Sequential()
# in_channel = image channel, filter count
phi_net.add_module('phi_0', _conv_block(self.in_channel, self.filter_count,
self.kernel_size, self.stride, self.padding))
for layer_idx in range(self.num_block_phi - 2):
phi_net.add_module(f"phi_{layer_idx + 1}",
_conv_block(self.filter_count, self.filter_count,
self.kernel_size, self.stride, self.padding))
phi_net.add_module(f'phi_{self.num_block_phi-1}', nn.Conv2d(self.filter_count, self.in_channel,
kernel_size=self.kernel_size, stride=self.stride, padding=self.padding))
phi_net.add_module('phi_final_activation', nn.Tanh())
return phi_net
def _psi_network(self):
psi_net = nn.Sequential()
# in_channel = image channel * 3 since it takes Image, phi_out, Image^(n+1)
psi_net.add_module('psi_0', _conv_block(3 * self.in_channel, self.filter_count,
self.kernel_size, self.stride, self.padding))
for layer_idx in range(self.num_block_psi - 2):
psi_net.add_module(f"psi_{layer_idx + 1}",
_conv_block(self.filter_count, self.filter_count,
self.kernel_size, self.stride, self.padding))
psi_net.add_module(f'psi_{self.num_block_psi-1}', nn.Conv2d(self.filter_count, self.in_channel,
kernel_size=self.kernel_size, stride=self.stride, padding=self.padding))
psi_net.add_module('psi_final_activation', nn.Sigmoid())
return psi_net
# PatchGAN with 11x11 Patch
class MarkovianDiscriminator(nn.Module):
# should be same as Phi network
def __init__(self, in_channel=3, filter_count=32, kernel_size=3, stride=1, padding=1, num_block=5):
super().__init__()
# in_channel = image channel, filter count
self.net = nn.Sequential()
self.net.add_module('discriminator_0', _conv_block(in_channel, filter_count, kernel_size, stride, padding))
for layer_idx in range(num_block - 2):
self.net.add_module(f"discriminator_{layer_idx + 1}",
_conv_block(filter_count, filter_count, kernel_size, stride, padding))
self.net.add_module('discriminator_4', nn.Conv2d(filter_count, 1,
kernel_size=kernel_size, stride=stride, padding=padding))
# TODO: add sigmoid or not?
# self.net.add_module('last_layer,activation', nn.Sigmoid())
def forward(self, x):
y = self.net(x)
return y
|
1681245
|
import unittest
from pony.thirdparty.compiler.transformer import parse
from pony.orm.decompiling import Decompiler
from pony.orm.asttranslation import ast2src
def generate_gens():
patterns = [
'(x * y) * [z * j)',
'([x * y) * z) * j',
'(x * [y * z)) * j',
'x * ([y * z) * j)',
'x * (y * [z * j))'
]
ops = ('and', 'or')
nots = (True, False)
result = []
for pat in patterns:
cur = pat
for op1 in ops:
for op2 in ops:
for op3 in ops:
res = cur.replace('*', op1, 1)
res = res.replace('*', op2, 1)
res = res.replace('*', op3, 1)
result.append(res)
final = []
for res in result:
for par1 in nots:
for par2 in nots:
for a in nots:
for b in nots:
for c in nots:
for d in nots:
cur = res.replace('(', 'not(') if not par1 else res
if not par2:
cur = cur.replace('[', 'not(')
else:
cur = cur.replace('[', '(')
if not a: cur = cur.replace('x', 'not x')
if not b: cur = cur.replace('y', 'not y')
if not c: cur = cur.replace('z', 'not z')
if not d: cur = cur.replace('j', 'not j')
final.append(cur)
return final
def create_test(gen):
def wrapped_test(self):
def get_condition_values(cond):
result = []
vals = (True, False)
for x in vals:
for y in vals:
for z in vals:
for j in vals:
result.append(eval(cond, {'x': x, 'y': y, 'z': z, 'j': j}))
return result
src1 = '(a for a in [] if %s)' % gen
src2 = 'lambda x, y, z, j: (%s)' % gen
src3 = '(m for m in [] if %s for n in [] if %s)' % (gen, gen)
code1 = compile(src1, '<?>', 'eval').co_consts[0]
ast1 = Decompiler(code1).ast
res1 = ast2src(ast1).replace('.0', '[]')
res1 = res1[res1.find('if')+2:-1]
code2 = compile(src2, '<?>', 'eval').co_consts[0]
ast2 = Decompiler(code2).ast
res2 = ast2src(ast2).replace('.0', '[]')
res2 = res2[res2.find(':')+1:]
code3 = compile(src3, '<?>', 'eval').co_consts[0]
ast3 = Decompiler(code3).ast
res3 = ast2src(ast3).replace('.0', '[]')
res3 = res3[res3.find('if')+2: res3.rfind('for')-1]
if get_condition_values(gen) != get_condition_values(res1):
self.fail("Incorrect generator decompilation: %s -> %s" % (gen, res1))
if get_condition_values(gen) != get_condition_values(res2):
self.fail("Incorrect lambda decompilation: %s -> %s" % (gen, res2))
if get_condition_values(gen) != get_condition_values(res3):
self.fail("Incorrect multi-for generator decompilation: %s -> %s" % (gen, res3))
return wrapped_test
class TestDecompiler(unittest.TestCase):
pass
for i, gen in enumerate(generate_gens()):
test_method = create_test(gen)
test_method.__name__ = 'test_decompiler_%d' % i
setattr(TestDecompiler, test_method.__name__, test_method)
|
1681264
|
import sys
import unittest
from pulsar.utils.exceptions import reraise
class TestMiscellaneous(unittest.TestCase):
def test_reraise(self):
self.assertRaises(RuntimeError, reraise, RuntimeError, RuntimeError())
try:
raise RuntimeError('bla')
except Exception:
exc_info = sys.exc_info()
self.assertRaises(RuntimeError, reraise, *exc_info)
|
1681271
|
from myapp.views import AuthorCreate, AuthorUpdate, AuthorDelete, AuthorListView, AuthorDetailView
from django.conf.urls import url
app_name = 'myapp'
urlpatterns = [
url(r'^author/$', AuthorListView.as_view(), name='author-list'),
url(r'^author/create/$', AuthorCreate.as_view(), name='author-create'),
url(r'^author/(?P<pk>[1-9]\d*)/$', AuthorDetailView.as_view(), name='author-detail'),
url(r'^author/(?P<pk>[1-9]\d*)/update/$', AuthorUpdate.as_view(), name='author-update'),
url(r'^author/(?P<pk>[1-9]\d*)/delete/$', AuthorDelete.as_view(), name='author-delete'),
]
|
1681349
|
import os
import os.path as osp
import sys
import pdb
import argparse
import librosa
import numpy as np
from tqdm import tqdm
import h5py
from PIL import Image
import subprocess
from options.test_options import TestOptions
import torchvision.transforms as transforms
import torch
import torchvision
from data.stereo_dataset import generate_spectrogram
from models.networks import VisualNet, VisualNetDilated, AudioNet, AssoConv, APNet, weights_init
def audio_normalize(samples, desired_rms = 0.1, eps = 1e-4):
rms = np.maximum(eps, np.sqrt(np.mean(samples**2)))
samples = samples * (desired_rms / rms)
return rms / desired_rms, samples
def main():
#load test arguments
opt = TestOptions().parse()
opt.device = torch.device("cuda")
## build network
# visual net
original_resnet = torchvision.models.resnet18(pretrained=True)
if opt.visual_model == 'VisualNet':
net_visual = VisualNet(original_resnet)
elif opt.visual_model == 'VisualNetDilated':
net_visual = VisualNetDilated(original_resnet)
else:
raise TypeError("please input correct visual model type")
if len(opt.weights_visual) > 0:
print('Loading weights for visual stream')
net_visual.load_state_dict(torch.load(opt.weights_visual), strict=True)
# audio net
net_audio = AudioNet(
ngf=opt.unet_ngf,
input_nc=opt.unet_input_nc,
output_nc=opt.unet_output_nc,
)
net_audio.apply(weights_init)
if len(opt.weights_audio) > 0:
print('Loading weights for audio stream')
net_audio.load_state_dict(torch.load(opt.weights_audio), strict=True)
# fusion net
if opt.fusion_model == 'none':
net_fusion = None
elif opt.fusion_model == 'AssoConv':
net_fusion = AssoConv()
elif opt.fusion_model == 'APNet':
net_fusion = APNet()
else:
raise TypeError("Please input correct fusion model type")
if net_fusion is not None and len(opt.weights_fusion) > 0:
net_fusion.load_state_dict(torch.load(opt.weights_fusion), strict=True)
net_visual.to(opt.device)
net_audio.to(opt.device)
net_visual.eval()
net_audio.eval()
if net_fusion is not None:
net_fusion.to(opt.device)
net_fusion.eval()
test_h5_path = opt.hdf5FolderPath
print("---Testing---: ", test_h5_path)
testf = h5py.File(test_h5_path, 'r')
audio_list = testf['audio'][:]
# ensure output dir
if not osp.exists(opt.output_dir_root):
os.mkdir(opt.output_dir_root)
for audio_file in tqdm(audio_list):
audio_file = bytes.decode(audio_file)
video_path = audio_file.replace('audio_resave', 'frames')[:-4]
input_audio_path = audio_file
video_frame_path = video_path
audio_id = audio_file.split('/')[-1][:-4]
cur_output_dir_root = os.path.join(opt.output_dir_root, audio_id)
#load the audio to perform separation
audio, audio_rate = librosa.load(input_audio_path, sr=opt.audio_sampling_rate, mono=False)
audio_channel1 = audio[0,:]
audio_channel2 = audio[1,:]
#define the transformation to perform on visual frames
vision_transform_list = [transforms.Resize((224,448)), transforms.ToTensor()]
vision_transform_list.append(transforms.Normalize(mean=[0.485, 0.456, 0.406], std=[0.229, 0.224, 0.225]))
vision_transform = transforms.Compose(vision_transform_list)
#perform spatialization over the whole audio using a sliding window approach
overlap_count = np.zeros((audio.shape)) #count the number of times a data point is calculated
binaural_audio = np.zeros((audio.shape))
#perform spatialization over the whole spectrogram in a siliding-window fashion
sliding_window_start = 0
data = {}
samples_per_window = int(opt.audio_length * opt.audio_sampling_rate)
while sliding_window_start + samples_per_window < audio.shape[-1]:
sliding_window_end = sliding_window_start + samples_per_window
normalizer, audio_segment = audio_normalize(audio[:,sliding_window_start:sliding_window_end])
audio_segment_channel1 = audio_segment[0,:]
audio_segment_channel2 = audio_segment[1,:]
audio_segment_mix = audio_segment_channel1 + audio_segment_channel2
audio_diff = torch.FloatTensor(generate_spectrogram(audio_segment_channel1 - audio_segment_channel2)).unsqueeze(0) #unsqueeze to add a batch dimension
audio_mix = torch.FloatTensor(generate_spectrogram(audio_segment_channel1 + audio_segment_channel2)).unsqueeze(0) #unsqueeze to add a batch dimension
#get the frame index for current window
frame_index = int(round((((sliding_window_start + samples_per_window / 2.0) / audio.shape[-1]) * opt.input_audio_length + 0.05) * 10 ))
image = Image.open(os.path.join(video_frame_path, str(frame_index) + '.jpg')).convert('RGB')
#image = image.transpose(Image.FLIP_LEFT_RIGHT)
frame = vision_transform(image).unsqueeze(0) #unsqueeze to add a batch dimension
# data to device
audio_diff = audio_diff.to(opt.device)
audio_mix = audio_mix.to(opt.device)
frame = frame.to(opt.device)
vfeat = net_visual(frame)
if net_fusion is not None:
upfeatures, output = net_audio(audio_diff, audio_mix, vfeat, return_upfeatures=True)
output.update(net_fusion(audio_mix, vfeat, upfeatures))
else:
output = net_audio(audio_diff, audio_mix, vfeat)
#ISTFT to convert back to audio
if opt.use_fusion_pred:
pred_left_spec = output['pred_left'][0,:,:,:].data[:].cpu().numpy()
pred_left_spec = pred_left_spec[0,:,:] + 1j * pred_left_spec[1,:,:]
reconstructed_signal_left = librosa.istft(pred_left_spec, hop_length=160, win_length=400, center=True, length=samples_per_window)
pred_right_spec = output['pred_right'][0,:,:,:].data[:].cpu().numpy()
pred_right_spec = pred_right_spec[0,:,:] + 1j * pred_right_spec[1,:,:]
reconstructed_signal_right = librosa.istft(pred_right_spec, hop_length=160, win_length=400, center=True, length=samples_per_window)
else:
predicted_spectrogram = output['binaural_spectrogram'][0,:,:,:].data[:].cpu().numpy()
reconstructed_stft_diff = predicted_spectrogram[0,:,:] + (1j * predicted_spectrogram[1,:,:])
reconstructed_signal_diff = librosa.istft(reconstructed_stft_diff, hop_length=160, win_length=400, center=True, length=samples_per_window)
reconstructed_signal_left = (audio_segment_mix + reconstructed_signal_diff) / 2
reconstructed_signal_right = (audio_segment_mix - reconstructed_signal_diff) / 2
reconstructed_binaural = np.concatenate((np.expand_dims(reconstructed_signal_left, axis=0), np.expand_dims(reconstructed_signal_right, axis=0)), axis=0) * normalizer
binaural_audio[:,sliding_window_start:sliding_window_end] = binaural_audio[:,sliding_window_start:sliding_window_end] + reconstructed_binaural
overlap_count[:,sliding_window_start:sliding_window_end] = overlap_count[:,sliding_window_start:sliding_window_end] + 1
sliding_window_start = sliding_window_start + int(opt.hop_size * opt.audio_sampling_rate)
#deal with the last segment
normalizer, audio_segment = audio_normalize(audio[:,-samples_per_window:])
audio_segment_channel1 = audio_segment[0,:]
audio_segment_channel2 = audio_segment[1,:]
audio_diff = torch.FloatTensor(generate_spectrogram(audio_segment_channel1 - audio_segment_channel2)).unsqueeze(0) #unsqueeze to add a batch dimension
audio_mix = torch.FloatTensor(generate_spectrogram(audio_segment_channel1 + audio_segment_channel2)).unsqueeze(0) #unsqueeze to add a batch dimension
#get the frame index for last window
frame_index = int(round(((opt.input_audio_length - opt.audio_length / 2.0) + 0.05) * 10))
image = Image.open(os.path.join(video_frame_path, str(frame_index) + '.jpg')).convert('RGB')
#image = image.transpose(Image.FLIP_LEFT_RIGHT)
frame = vision_transform(image).unsqueeze(0) #unsqueeze to add a batch dimension
# data to device
audio_diff = audio_diff.to(opt.device)
audio_mix = audio_mix.to(opt.device)
frame = frame.to(opt.device)
vfeat = net_visual(frame)
if net_fusion is not None:
upfeatures, output = net_audio(audio_diff, audio_mix, vfeat, return_upfeatures=True)
output.update(net_fusion(audio_mix, vfeat, upfeatures))
else:
output = net_audio(audio_diff, audio_mix, vfeat)
#ISTFT to convert back to audio
if opt.use_fusion_pred:
pred_left_spec = output['pred_left'][0,:,:,:].data[:].cpu().numpy()
pred_left_spec = pred_left_spec[0,:,:] + 1j * pred_left_spec[1,:,:]
reconstructed_signal_left = librosa.istft(pred_left_spec, hop_length=160, win_length=400, center=True, length=samples_per_window)
pred_right_spec = output['pred_right'][0,:,:,:].data[:].cpu().numpy()
pred_right_spec = pred_right_spec[0,:,:] + 1j * pred_right_spec[1,:,:]
reconstructed_signal_right = librosa.istft(pred_right_spec, hop_length=160, win_length=400, center=True, length=samples_per_window)
else:
predicted_spectrogram = output['binaural_spectrogram'][0,:,:,:].data[:].cpu().numpy()
reconstructed_stft_diff = predicted_spectrogram[0,:,:] + (1j * predicted_spectrogram[1,:,:])
reconstructed_signal_diff = librosa.istft(reconstructed_stft_diff, hop_length=160, win_length=400, center=True, length=samples_per_window)
reconstructed_signal_left = (audio_segment_mix + reconstructed_signal_diff) / 2
reconstructed_signal_right = (audio_segment_mix - reconstructed_signal_diff) / 2
reconstructed_binaural = np.concatenate((np.expand_dims(reconstructed_signal_left, axis=0), np.expand_dims(reconstructed_signal_right, axis=0)), axis=0) * normalizer
#add the spatialized audio to reconstructed_binaural
binaural_audio[:,-samples_per_window:] = binaural_audio[:,-samples_per_window:] + reconstructed_binaural
overlap_count[:,-samples_per_window:] = overlap_count[:,-samples_per_window:] + 1
#divide aggregated predicted audio by their corresponding counts
predicted_binaural_audio = np.divide(binaural_audio, overlap_count)
#check output directory
if not os.path.isdir(cur_output_dir_root):
os.mkdir(cur_output_dir_root)
mixed_mono = (audio_channel1 + audio_channel2) / 2
librosa.output.write_wav(os.path.join(cur_output_dir_root, 'predicted_binaural.wav'), predicted_binaural_audio, opt.audio_sampling_rate)
librosa.output.write_wav(os.path.join(cur_output_dir_root, 'mixed_mono.wav'), mixed_mono, opt.audio_sampling_rate)
librosa.output.write_wav(os.path.join(cur_output_dir_root, 'input_binaural.wav'), audio, opt.audio_sampling_rate)
if __name__ == '__main__':
main()
|
1681358
|
import matplotlib.pyplot as plt
import numpy as np
from matplotlib.colors import ListedColormap
def decision_regions(x, y, classifier, test_idx=None, resolution=0.02, plot_support=False, plot_custom_support=False):
markers = ('s', 'x', 'o', '^', 'v')
colors = ('red', 'blue', 'lightgreen', 'gray', 'cyan')
cmap = ListedColormap(colors[:len(np.unique(y))])
x1_min, x1_max = x[:, 0].min() - 1, x[:, 0].max() + 1
x2_min, x2_max = x[:, 1].min() - 1, x[:, 1].max() + 1
xx1, xx2 = np.meshgrid(
np.arange(x1_min, x1_max, resolution),
np.arange(x2_min, x2_max, resolution)
)
#z = classifier.predict(np.array([xx1.ravel(), xx2.ravel()]).T)
xy = np.array([xx1.ravel(), xx2.ravel()]).T
z = classifier.decision_function(xy) #.reshape(x.shape)
z = z.reshape(xx1.shape)
plt.contour(xx1, xx2, z, alpha=0.3, cmap=cmap, levels=[-1, 0, 1], linestyles=['--', '-', '--'])
plt.xlim(xx1.min(), xx1.max())
plt.ylim(xx2.min(), xx2.max())
for idx, c1 in enumerate(np.unique(y)):
plt.scatter(
x=x[y == c1, 0], y=x[y == c1, 1],
alpha=0.8, c=colors[idx],
marker=markers[idx], label=c1,
edgecolors='none'
)
if test_idx:
x_test, y_test = x[test_idx,:], y[test_idx]
plt.scatter(
x_test[:,0],
x_test[:,1],
c='none',
edgecolors='green',
alpha=1.0, linewidth=1,
marker='o',
s=250,
label='test set')
if plot_support:
plt.scatter(
classifier.support_vectors_[:, 0],
classifier.support_vectors_[:, 1],
marker='o',
s=100,
c='none',
alpha=1.0,
linewidth=1,
edgecolors='purple',
#facecolors='none',
label='support set'
)
if plot_custom_support:
preds = classifier.decision_function(x)
support_vectors = np.where(abs(preds) <= 1, 1, 0)
#print(support_vectors)
support_vector_idxs = np.where(support_vectors == 1)[0]
#print(support_vector_idxs)
x_support = x[support_vector_idxs, :]
plt.scatter(
x_support[:, 0],
x_support[:, 1],
marker='o',
s=200,
c='none',
alpha=1.0,
linewidth=1,
edgecolors='orange',
facecolors='none',
label='custom support set'
)
|
1681438
|
from tkinter import *
root = Tk()
root.geometry("200x200+500+300")
label = Label(text=1)
label.pack()
entryText = StringVar()
entryText.set("<NAME>")
entry = Entry(textvariable=entryText)
entry.pack()
button = Button(command=lambda: label.configure(text=label.cget("text") + 1))
button.pack()
root.mainloop()
|
1681443
|
from TikTokLive import TikTokLiveClient
from TikTokLive.types.events import AbstractEvent, GiftEvent
# Instantiate the client with debug param as true
client: TikTokLiveClient = TikTokLiveClient(unique_id="@best.printer", debug=True)
@client.on("gift")
async def on_gift(event: GiftEvent):
# When gifts are sent
print(event.user.uniqueId, event.gift.extended_gift.name)
# Only fires when debug is set to True
@client.on("debug")
async def on_debug(event: AbstractEvent):
# Receive the raw, unprocessed event dictionaries
if "gift" in event.as_dict.keys():
print(event.as_dict)
if __name__ == '__main__':
# Run the client and block the main thread
# await client.start() to run non-blocking
client.run()
|
1681453
|
import warnings
from typing import Optional, Union
from ansys.mapdl.core.mapdl_types import MapdlInt
class Style:
def cplane(self, key="", **kwargs):
"""Specifies the cutting plane for section and capped displays.
APDL Command: /CPLANE
Parameters
----------
key
Specifies the cutting plane:
0 - Cutting plane is normal to the viewing vector [/VIEW] and passes through the
focus point [/FOCUS] (default).
1 - The working plane [WPLANE] is the cutting plane.
Notes
-----
Defines the cutting plane to be used for section and capped displays
[/TYPE,,(1, 5, or 7)].
This command is valid in any processor.
"""
command = f"/CPLANE,{key}"
return self.run(command, **kwargs)
def ctype(self, key="", dotd="", dots="", dshp="", tlen="", **kwargs):
"""Specifies the type of contour display.
APDL Command: /CTYPE
Parameters
----------
key
Type of display:
0 - Standard contour display.
1 - Isosurface display.
2 - Particle gradient display.
3 - Gradient triad display.
dotd
Maximum dot density for particle gradient display (KEY = 2).
Density is expressed as dots per screen width (defaults to 30).
dots
Dot size for particle gradient display (KEY = 2). Size is
expressed as a fraction of the screen width (defaults to 0.0
(single dot width)).
dshp
Spherical dot shape precision for particle gradient display (KEY =
2). (3-D options are supported only on 3-D devices):
0 - Flat 2-D circular dot.
1 - Flat-sided 3-D polyhedron.
n - 3-D sphere with n (>1) polygon divisions per 90° of radius.
tlen
Maximum length of triads for gradient triad display (KEY = 3).
Value is expressed as a fraction of the screen width (defaults to
0.067).
Notes
-----
Use /CTYPE,STAT to display the current settings. Only the standard
contour display [/CTYPE,0) and the isosurface contour display
[/CTYPE,1] are supported by PowerGraphics [/GRAPHICS,POWER].
This command is valid in any processor.
"""
command = f"/CTYPE,{key},{dotd},{dots},{dshp},{tlen}"
return self.run(command, **kwargs)
def edge(self, wn="", key="", angle="", **kwargs):
"""Displays only the common lines ("edges") of an object.
APDL Command: /EDGE
Parameters
----------
wn
Window number (or ALL) to which command applies. The default window
is 1.
key
Edge key:
0 - Display common lines between all adjacent element faces.
1 - Display only the common lines between non-coplanar faces (that is, show only
the edges).
angle
Largest angle between two faces for which the faces are considered
to be coplanar (0° to 180°). Defaults to 45°. A smaller angle
produces more edges, a larger angle produces fewer edges.
Notes
-----
The ANGLE field is used in PowerGraphics to determine geometric
discontinuities. It is a tolerance measure for the differences between
the normals of the surfaces being considered. Values within the
tolerance are accepted as coplanar (geometrically continuous). In
postprocessing displays, results are not averaged across discontinuous
surfaces.
A surface can be displayed as an edge outline without interior detail.
This is useful for both geometry and postprocessing displays. Element
outlines are normally shown as solid lines for geometry and
displacement displays. Lines common to adjacent "coplanar" element
faces are removed from the display. Midside nodes of elements are
ignored.
The /SHRINK option is ignored with the edge option.
/EDGE is not supported for PLESOL and /ESHAPE displays when in
PowerGraphics mode (/GRAPHICS,POWER).
The /EDGE command is valid in any processor.
"""
command = f"/EDGE,{wn},{key},{angle}"
return self.run(command, **kwargs)
def eshape(
self, scale: Union[str, int] = "", key: MapdlInt = "", **kwargs
) -> Optional[str]:
"""Displays elements with shapes determined from the real constants or section definition.
APDL Command: /ESHAPE
Parameters
----------
scale
Scaling factor:
* 0 - Use simple display of line and area elements. This
value is the default.
* 1 - Use real constants or section definition to form a
solid shape display of the applicable elements.
FAC - Multiply certain real constants, such as thickness,
by FAC (where FAC > 0.01) and use them to form a
solid shape display of elements.
key
Current shell thickness key:
* 0 - Use current thickness in the displaced solid shape
display of shell elements (valid for SHELL181,
SHELL208, SHELL209, and SHELL281). This value is the
default.
* 1 - Use initial thickness in the displaced solid shape
display of shell elements.
Notes
-----
The /ESHAPE command allows beams, shells, current sources, and
certain special-purpose elements to be displayed as solids
with the shape determined from the real constants or section
types. Elements are displayed via the EPLOT command. No checks
for valid or complete input are made for the display.
Following are details about using this command with various
element types:
SOLID65 elements are displayed with internal lines that
represent rebar sizes and orientations (requires vector mode
[/DEVICE] with a basic type of display [/TYPE,,BASIC]). The
rebar with the largest volume ratio in each element plots as a
red line, the next largest as green, and the smallest as blue.
COMBIN14, COMBIN39, and MASS21 are displayed with a graphics
icon, with the offset determined by the real constants and
KEYOPT settings.
BEAM188, BEAM189, PIPE288, PIPE289 and ELBOW290 are displayed
as solids with the shape determined via the section-definition
commands (SECTYPE and SECDATA). The arbitrary section option
(Subtype = ASEC) has no definite shape and appears as a thin
rectangle to show orientation. The elements are displayed with
internal lines representing the cross- section mesh.
SOLID272 and SOLID273 are displayed as solids with the shape
determined via the section-definition commands (SECTYPE and
SECDATA). The 2-D master plane is revolved around the
prescribed axis of symmetry.
Contour plots are available for these elements in
postprocessing for PowerGraphics only (/GRAPHICS,POWER). To
view 3-D deformed shapes for the elements, issue OUTRES,MISC
or OUTRES,ALL for static or transient analyses. To view 3-D
mode shapes for a modal or eigenvalue buckling analysis,
expand the modes with element results calculation ON (Elcalc =
YES for MXPAND).
SOURC36, CIRCU124, and TRANS126 elements always plot using
/ESHAPE when PowerGraphics is activated (/GRAPHICS,POWER).
In most cases, /ESHAPE renders a thickness representation of
your shell, plane and layered elements more readily in
PowerGraphics (/GRAPHICS,POWER). This type of representation
employs PowerGraphics to generate the enhanced representation,
and will often provide no enhancement in Full Graphics
(/GRAPHICS,FULL). This is especially true for POST1 results
displays, where /ESHAPE is not supported for most element
types with FULL graphics.
When PowerGraphics is active, /ESHAPE may degrade the image if
adjacent elements have overlapping material, such as shell
elements which are not co-planar. Additionally, if adjacent
elements have different thicknesses, the polygons depicting
the connectivity between the "thicker" and "thinner" elements
along the shared element edges may not always be displayed.
For POST1 results displays (such as PLNSOL), the following
limitations apply:
Rotational displacements for beam elements are used to create
a more realistic displacement display. When /ESHAPE is active,
displacement plots (via PLNSOL,U,X and PLDISP, for example)
may disagree with your PRNSOL listings. This discrepancy will
become more noticeable when the SCALE value is not equal to
one.
When shell elements are not co-planar, the resulting PLNSOL
display with /ESHAPE will actually be a PLESOL display as the
non-coincident pseudo-nodes are not averaged. Additionally,
/ESHAPE should not be used with coincident elements because
the plot may incorrectly average the displacements of the
coincident elements.
When nodes are initially coincident and PowerGraphics is
active, duplicate polygons are eliminated to conserve display
time and disk space. The command may degrade the image if
initially coincident nodes have different displacements. The
tolerance for determining coincidence is 1E-9 times the
model’s bounding box diagonal.
If you want to view solution results (PLNSOL, etc.) on layered
elements (such as SHELL181, SOLSH190, SOLID185 Layered Solid,
SOLID186 Layered Solid, SHELL208, SHELL209, SHELL281, and
ELBOW290), set KEYOPT(8) = 1 for the layer elements so that
the data for all layers is stored in the results file.
You can plot the through-thickness temperatures of elements
SHELL131 and SHELL132 regardless of the thermal DOFs in use by
issuing the PLNSOL,TEMP command (with PowerGraphics and
/ESHAPE active).
The /ESHAPE,1 and /ESHAPE,FAC commands are incompatible with
the /CYCEXPAND command used in cyclic symmetry analyses.
This command is valid in any processor.
"""
warnings.warn(
"pymapdl does not support /ESHAPE when plotting in "
"Python using ``mapdl.eplot()``. "
"Use ``mapdl.eplot(vtk=False)`` "
)
command = f"/ESHAPE,{scale},{key}"
return self.run(command, **kwargs)
def facet(self, lab="", **kwargs):
"""Specifies the facet representation used to form solid model displays.
APDL Command: /FACET
Parameters
----------
lab
Valid labels:
FINE - Use finer tessellation to increase the number of facets for the display.
Provides the best representation (but decreases speed of
operation).
NORML - Use the basic number of facets for the display (default).
COAR - Use a limited number of facets for the display. This option will increase the
speed of the operations, but may produce poor
representations for some imported models.
WIRE - Display model with a wireframe representation (fast, but surfaces will not be
shown).
Notes
-----
Specifies the facet (or polygon) representation used to form solid
model displays. Used only with the APLOT, ASUM, VPLOT, and VSUM
commands.
This command is valid in any processor.
"""
command = f"/FACET,{lab}"
return self.run(command, **kwargs)
def gline(self, wn="", style="", **kwargs):
"""Specifies the element outline style.
APDL Command: /GLINE
Parameters
----------
wn
Window number (or ALL) to which command applies (defaults to 1).
style
Outline key:
0 - Solid element outlines (default)
1 - Dashed element outlines
-1 - No element outlines
Notes
-----
Determines the element outline style. Often used when node numbers are
displayed to prevent element lines from overwriting node numbers.
Unless you are using an OpenGL or Starbase driver, the dashed element
outline option (/GLINE,WN,1) is not available in the following
situations:
Z-buffered displays (/TYPE,WN,6).
Capped Z-buffered displays (/TYPE,WN,7).
Qslice Z-buffered displays (/TYPE,WN,8).
This command is valid in any processor.
"""
command = f"/GLINE,{wn},{style}"
return self.run(command, **kwargs)
def gmarker(self, curve="", key="", incr="", **kwargs):
"""Specifies the curve marking style.
APDL Command: /GMARKER
Parameters
----------
curve
Curve number markers will be applied on (integer value between 1
and 10).
key
Marker key:
0 - No markers will be applied (default).
1 - TRIANGLES will be applied.
2 - SQUARES will be applied.
3 - DIAMONDS will be applied.
4 - CROSSES will be applied.
incr
Determines the curve marking frequency. (a whole number value
between 1 and 255). If INCR = 1, markers are displayed at every
data point on the curve. If INCR = 2 then markers are displayed at
every second data point. If INCR = 3 then they are displayed at
every third data point.
Notes
-----
The user-specified markers will not be drawn when the area under the
curve is color-filled (/GROPT, FILL).
"""
command = f"/GMARKER,{curve},{key},{incr}"
return self.run(command, **kwargs)
def gmface(self, lab="", n="", **kwargs):
"""Specifies the facet representation used to form solid models.
APDL Command: GMFACE
Parameters
----------
lab
Valid Labels:
FINE - Value that determines how coarse the facets will be.
n
An integer value between one (small) and ten (large) that
determines the tolerances that will be applied to the creation of
arcs and surfaces. Ten will create many facets, which may in turn
cause ANSYS to run very slowly. One will create fewer facets, which
may in turn cause larger tolerance errors.
"""
command = f"GMFACE,{lab},{n}"
return self.run(command, **kwargs)
def light(self, wn="", num="", int_="", xv="", yv="", zv="", refl="", **kwargs):
"""Specifies the light direction for the display window.
APDL Command: /LIGHT
Parameters
----------
wn
Window number (or ALL) to which command applies (defaults to 1).
num
Ambient or directional light key:
0 - Ambient light (default).
1 - Directional light.
int\_
Light intensity factor (defaults to 0.3 for ambient, 1.0 for
directional). This option is valid only for 3-D devices).
xv, yv, zv
Light direction (valid only for NUM = 1). The directional light
source is parallel to the line from point XV, YV, ZV to the origin,
in the global Cartesian system origin. Defaults to the viewing
direction [/VIEW].
refl
Light reflectance factor (valid only for NUM = 1 and 3-D devices).
Notes
-----
Defines the light direction for the window. Use this command only with
3-D graphics devices or 2-D devices when Z-buffering is used [/TYPE,,(6
or 7)]. The ambient light has no direction, only an intensity. You
can position the directional light source by defining a point (in the
global Cartesian coordinate system) representing a point along the
light directional line. This point, and the global Cartesian
coordinate system origin, define the line along which the light is
positioned looking toward the origin. You can use any point along the
light line; for example, both (1.,1.,1.) and (2.,2.,2.) give the same
light effect. For 3-D graphics devices only, the directional light
source also has intensity and reflectance factors.
By choosing the highest intensity ambient light for 3-D graphics
devices (via the command /LIGHT,WN,0,1), you can nullify color shading
and other effects of directional lighting.
This command is valid in any processor.
"""
command = f"/LIGHT,{wn},{num},{int_},{xv},{yv},{zv},{refl}"
return self.run(command, **kwargs)
def normal(self, wn="", key="", **kwargs):
"""Allows displaying area elements by top or bottom faces.
APDL Command: /NORMAL
Parameters
----------
wn
Window number (or ALL) to which command applies (defaults to 1).
key
Display key:
0 - No face distinction.
1 - Show only area elements having their positive normals directed toward the
viewing point.
-1 - Show only area elements having their positive normals directed away from the
viewing point.
Notes
-----
/NORMAL allows you to select area elements and area plots by the top or
bottom faces. It is useful for checking the normal directions on shell
elements. The positive normal (element Z direction) is defined by the
right-hand rule following the node I, J, K, L input direction. This
command is available only with raster or hidden-line displays, for
WIN32 or X11 2-D displays only.
This command is valid in any processor.
"""
command = f"/NORMAL,{wn},{key}"
return self.run(command, **kwargs)
def shade(self, wn="", type_="", **kwargs):
"""Defines the type of surface shading used with Z-buffering.
APDL Command: /SHADE
Parameters
----------
wn
Window number (or ALL) to which command applies (defaults to 1).
type\_
Shading type:
FACET or 0 - Facet shading (one color per area face) (default).
GOURAUD or 1 - Gouraud smooth shading (smooth variation of color based on interpolated vertex
colors).
PHONG or 2 - Phong smooth shading (smooth variation of color based on interpolated vertex
normals).
Notes
-----
Defines the type of surface shading used on area, volume, and
PowerGraphics [/GRAPHICS,POWER] displays when software Z-buffering is
enabled [/TYPE]. This command is only functional for 2-D display
devices.
This command is valid in any processor.
"""
command = f"/SHADE,{wn},{type_}"
return self.run(command, **kwargs)
def trlcy(self, lab="", tlevel="", n1="", n2="", ninc="", **kwargs):
"""Specifies the level of translucency.
APDL Command: /TRLCY
Parameters
----------
lab
Apply translucency level to the items specified by the following
labels:
ELEM - Elements. Use N1, N2, NINC fields for element numbers.
AREA - Solid model areas. Use N1, N2, NINC fields for area numbers.
VOLU - Solid model volumes. Use N1, N2, NINC fields for volume numbers.
ISURF - Isosurfaces (surfaces of constant stress, etc., value). Translucency varies
with result value, to a maximum of the specified
translucency level.
CM - Component group. Use N1 for component name, ignore N2 and NINC.
CURVE - Filled areas under curves of line graphs. Use N1, N2, NINC fields for curve
numbers.
ZCAP - If /TYPE,WN,ZCAP is the current display type, then /TRLCY,ZCAP,TLEVEL will
display the model in window WN with the portion of the model
in front of the section plane displayed at the translucency
level TLEVEL.
ON, OFF - Sets the specified translucency display on or off. All other fields are
ignored.
tlevel
Translucency level: 0.0 (opaque) to 1.0 (transparent).
n1, n2, ninc
Used only with labels as noted above. Apply translucency level to
Lab items numbered N1 to N2 (defaults to N1) in steps of NINC
(defaults to 1). If N1 is blank or ALL, apply specified
translucency level to entire selected range. If Lab is CM, use
component name for N1 and ignore N2 and NINC. A value of N1 = P
allows you to graphically pick elements, areas, and volumes. You
can then assign translucency levels to the entities via the picker.
The Lab and TLEVEL fields are ignored when translucency is applied
by picking.
Notes
-----
Specifies the level of translucency for various items. Issue
/TRLCY,DEFA to reset the default (0) translucency levels. This command
is valid only on selected 2-D and 3-D graphics devices; see in the
Basic Analysis Guide for more information on applying translucency.
For 2-D devices, ANSYS displays only the visible faces of the items
being displayed. The information behind the facing planes is not
displayed. Issuing the /SHRINK command will force the hardware to
display information behind the translucent items.
This command is valid in any processor.
"""
command = f"/TRLCY,{lab},{tlevel},{n1},{n2},{ninc}"
return self.run(command, **kwargs)
|
1681548
|
import boto.rds
from datetime import date, timedelta,datetime
from dateutil.parser import parse
import csv
days_counter=45
region="ap-southeast-1"
conn = boto.rds.connect_to_region(region)
# amis=ec2conn.get_all_images(owners='self')
print conn.get_all_dbsnapshots()
print type(conn.get_all_dbsnapshots())
# class Ami:
# def __init__(self,ec2_ami):
# self.id = ec2_ami.id
# self.strpdate = parse(ec2_ami.creationDate).date()
#
#
#
# Computing Older date
# old = datetime.today() - timedelta(days_counter)
# old_date=old.date()
#
# Fetching All AMI's
# ec2conn = boto.ec2.connect_to_region(region)
# amis=ec2conn.get_all_images(owners='self')
#
# print "Today's date : " + str(datetime.today())
# print "Finding AMI's older than : " + str(old_date)
#
# older_list = []
# for ami in amis:
# older_list = [ami for ami in amis if parse(ami.creationDate).date() < old_date ]
#
#
#
# for item in older_list:
# print item.id + "," + item.name + "," + item.creationDate
#
# print "Total : " + str(len(older_list))
#
|
1681584
|
class Solution:
def nextGreaterElement(self, n: int) -> int:
n = list(str(n))
i = j = len(n) - 1
while i and n[i-1] >= n[i]:
i -= 1
if not i:
return -1
while n[j] <= n[i-1]:
j -= 1
n[i-1], n[j] = n[j], n[i-1]
n = int(''.join(n[:i] + n[i:][::-1]))
return n if 1 < n < 2**31-1 else -1
|
1681585
|
from a import burn
from a import Toaster
print 'In b.py, at import time:', burn
print 'In b.py, at import time, Toaster:', Toaster
def toast():
print 'In b.py, at runtime:', burn
print 'In b.py, at runtime, Toaster:', Toaster
print 'In b.py, at runtime, Toaster.burn:', Toaster.burn
burn()
Toaster.burn()
return True
|
1681601
|
from city_scrapers_core.constants import ADVISORY_COMMITTEE
from city_scrapers_core.spiders import CityScrapersSpider
from city_scrapers.mixins import CuyaCountyMixin
class CuyaArchivesAdvisorySpider(CuyaCountyMixin, CityScrapersSpider):
name = "cuya_archives_advisory"
agency = "Cuyahoga County Archives Advisory Commission"
start_urls = ["http://bc.cuyahogacounty.us/en-US/Archives-Advisory-Commission.aspx"]
classification = ADVISORY_COMMITTEE
location = {
"name": "Cuyahoga County Archives Building, 3rd Floor",
"address": "3951 Perkins Ave Cleveland, OH 44114",
}
def _parse_location(self, response):
loc_str = super()._parse_location(response)
if "Perkins" in loc_str:
return self.location
return {"name": "", "address": loc_str}
|
1681645
|
import spacy
from initialize import spacy_nlp
from interfaces.SentenceOperation import SentenceOperation
from interfaces.SentencePairOperation import SentencePairOperation
from tasks.TaskTypes import TaskType
"""
Auxiliary Negation Removal.
Remove auxiliary negations generating a sentence with oposite meaning.
"""
def auxiliary_negation_removal(sentence, nlp):
"""returns (arg1 / arg2) + arg3
This functions removes auxiliary negations when present.
:param sentence: sentence to process
:param nlp: spacy pipeline for tokenization
:type sentence: str
:type nlp: spacy module
:returns: sprocessed sentences
:rtype: str
"""
# Tokenize Sentence
doc = nlp(sentence)
# Initialize Variables
changed = False
new_sentence = []
supported_auxiliaries = [
"am",
"are",
"can",
"could",
"had",
"has",
"have",
"is",
"may",
"might",
"must",
"shall",
"should",
"was",
"were",
"will",
"would",
]
# Evaluate Tokens
for token in doc:
# Add Token to Output Sentence
new_sentence.append(token)
# Initialize Variables
token_lowercased_lemma = token.lemma_.lower()
# Process Negations
if token_lowercased_lemma == "not" or token_lowercased_lemma == "n't":
# Get not position
not_index = token.i
# Process Auxiliaries
if not_index > 0:
# Get Previous Token
previous_index = not_index - 1
previous_token = doc[previous_index]
previous_surface = previous_token.text
previous_lowercase_surface = previous_surface.lower()
# Remove Negation
if previous_lowercase_surface in supported_auxiliaries:
new_sentence = new_sentence[:-1]
changed = True
elif previous_lowercase_surface in ["do"]:
new_sentence = new_sentence[:-2]
changed = True
# Handle Spacing
if (
token_lowercased_lemma == "n't"
and changed
and new_sentence
):
new_sentence[-1] = nlp(
new_sentence[-1].text + token.whitespace_
)[0]
# Rebuild Sentence
new_sentence = [t.text + t.whitespace_ for t in new_sentence]
new_sentence = "".join(new_sentence)
return (new_sentence, changed)
class SentenceAuxiliaryNegationRemoval(SentenceOperation):
tasks = [
TaskType.TEXT_CLASSIFICATION,
TaskType.TEXT_TO_TEXT_GENERATION,
TaskType.QUALITY_ESTIMATION,
]
languages = ["en"]
keywords = [
"morphological",
"lexical",
"rule-based",
"tokenizer-required",
"meaning-alteration",
"high-precision",
"low-coverage",
"low-generations",
"causal-reasoning",
]
def __init__(self, seed=0, max_outputs=1):
super().__init__(seed, max_outputs=max_outputs)
self.nlp = spacy_nlp if spacy_nlp else spacy.load("en_core_web_sm")
def generate(self, sentence: str):
# Initialize Variables
output_sentence = sentence
# Process sentence
new_sentence, changed = auxiliary_negation_removal(sentence, self.nlp)
if changed:
output_sentence = new_sentence
return [output_sentence]
class PairAuxiliaryNegationRemoval(SentencePairOperation):
tasks = [TaskType.PARAPHRASE_DETECTION]
languages = ["en"]
keywords = [
"morphological",
"lexical",
"rule-based",
"tokenizer-required",
"meaning-alteration",
"high-precision",
"low-coverage",
"low-generations",
"causal-reasoning",
]
def __init__(self, seed=0, max_outputs=3, pos_label="1", neg_label="0"):
super().__init__(seed, max_outputs=max_outputs)
self.nlp = spacy_nlp if spacy_nlp else spacy.load("en_core_web_sm")
self.pos_label = pos_label
self.neg_label = neg_label
def generate(self, sentence1: str, sentence2: str, target: str):
# Initialize Variables
output_sentences = []
changed_sentences = {}
# Only process equivalent pairs
if target == self.pos_label:
for n, sentence in enumerate([sentence1, sentence2]):
# Process sentence
new_sentence, changed = auxiliary_negation_removal(
sentence, self.nlp
)
if changed:
changed_sentences[n] = new_sentence
if 0 in changed_sentences.keys():
output_sentences.append(
(changed_sentences[0], sentence2, self.neg_label)
)
if 1 in changed_sentences.keys():
output_sentences.append(
(sentence1, changed_sentences[1], self.neg_label)
)
if 0 in changed_sentences.keys() and 1 in changed_sentences.keys():
output_sentences.append(
(changed_sentences[0], changed_sentences[1], self.pos_label)
)
if not output_sentences:
output_sentences = [(sentence1, sentence2, target)]
return output_sentences
"""
# Sample code to demonstrate usage. Can also assist in adding test cases.
# You don't need to keep this code in your transformation.
if __name__ == '__main__':
import json
from TestRunner import convert_to_snake_case
tf = SentenceAuxiliaryNegationRemoval()
test_cases = []
for sentence["Andrew has not returned the French book to the library.",
"Sentences with gapping, such as Paul likes coffee and Mary tea, do not have an overt predicate.",
"Alice in Wonderland isn't a 1997 American live-action/animated dark fantasy adventure film.",
"Ujjal Dev Dosanjh was not the 1st Premier of British Columbia from 1871 to 1872.",
"The fighters would not give up."]:
test_cases.append({
"class": tf.name(),
"inputs": {"sentence": sentence},
"outputs": [{"sentence": o[0]} for o in tf.generate(sentence)]}
)
json_file = {"type": convert_to_snake_case(tf.name()), "test_cases": test_cases}
print(json.dumps(json_file))
tf = PairAuxiliaryNegationRemoval(max_outputs=3)
test_cases = []
for sentence1, sentence2, target in zip(["Andrew has not returned the French book to the library.",
"Sentences with gapping, such as Paul likes coffee and Mary tea, do not have an overt predicate.",
"<NAME> Wonderland isn't a 1997 American live-action/animated dark fantasy adventure film.",
"<NAME> was not the 1st Premier of British Columbia from 1871 to 1872.",
"The fighters would not give up."],
["He hasn't brought back the library's books.",
"Gapping sentences, such as Paul likes coffee and Mary tea, lack an overt predicate.",
"Alice in Wonderland is not an American animated, dark fantasy adventure film from 1997.",
"U.<NAME> wasn't the 1st Premier of British Columbia for a year from 1871.",
"The warriors wouldn't leave the battlefield."],
["1",
"1",
"1",
"1",
"1"
]
):
test_cases.append({
"class": tf.name(),
"inputs": {"sentence1": sentence1, "sentence2": sentence2, "target": target},
"outputs": [{"sentence1": o[0], "sentence2": o[1], "target": o[2]} for o in tf.generate(sentence1, sentence2, target)]}
)
json_file = {"type": convert_to_snake_case(tf.name()), "test_cases": test_cases}
print(json.dumps(json_file))
"""
|
1681748
|
import Orange
data = Orange.data.Table("iris.tab")
print("Dataset instances:", len(data))
subset = Orange.data.Table(data.domain, [d for d in data if d["petal length"] > 3.0])
print("Subset size:", len(subset))
|
1681757
|
from dataclasses import dataclass, field
from typing import Optional
@dataclass
class QvaPayError(Exception):
status_code: int
status_message: Optional[str] = field(default=None)
|
1681775
|
import json
import random
import re
import time
from urllib.parse import quote_plus
from v2ray_pool import Net
import chardet
import requests
import urllib3
from bs4 import BeautifulSoup
from my_fake_useragent import UserAgent
class Keywords(Net):
'''url:https://www.5118.com/ciku/index#129'''
def get_keys_by_net(self) -> []:
try:
r = self.request(r'https://www.5118.com/ciku/index#129')
if r.status_code != 200:
return None
r.encoding = r.apparent_encoding
# <span>法律</span><br>
soup = BeautifulSoup(r.text, "html.parser")
results = []
for a in soup.find_all(name='a'):
results += re.findall(r'<span>(.*?)</span><br', str(a.get_text), re.DOTALL)
return results
except Exception as e:
print(e)
return None
def get_keys_by_local(self) -> []:
with open('test/key_tag.json', 'r') as f:
js_get = json.load(f)
f.close()
return js_get
def get_titles_by_local(self) -> []:
with open('test/key_title.json', 'r') as f:
js_get = json.load(f)
f.close()
return js_get
def get_titles_by_net(self, key):
'''通过网盘搜索检查出
https://www.alipanso.com/search.html?page=1&keyword=%E7%90%86%E8%B4%A2&search_folder_or_file=2&is_search_folder_content=1&is_search_path_title=1&category=doc&file_extension=doc&search_model=1
'''
results = []
try:
time.sleep(random.randint(1, 4))
r = self.request_en(
r'https://www.alipanso.com/search.html?page=1&keyword=%s&search_folder_or_file=2&is_search_folder_content=1&is_search_path_title=1&category=doc&file_extension=doc&search_model=1' % key)
if r.status_code != 200:
print(r.status_code)
return None
r.encoding = r.apparent_encoding
soup = BeautifulSoup(r.text, "html.parser")
for a in soup.find_all(name='a'):
ts = re.findall(r'(.*?).doc', str(a.get_text()).replace('\n', ''), re.DOTALL)
for t in ts:
if '公众号' in t or '【' in t or '[' in t or ',' in t or ',' in t or ')' in t or ')' in t or t in results:
continue
if len(t) < 4:
continue
results.append(t)
return results
except Exception as e:
print(e)
return None
def test():
js = ['a', 'b', 'c']
with open('test/key_tag.json', 'w') as f:
json.dump(js, f)
f.close()
with open('test/key_tag.json', 'r') as f:
js_get = json.load(f)
f.close()
print(js_get)
if __name__ == "__main__":
# test()
keys = Keywords().get_keys_by_net()
print(keys)
with open('test/key_tag.json', 'w') as f:
json.dump(keys, f, ensure_ascii=False)
f.close()
|
1681790
|
from discord.ext import commands
import config
class Games(commands.Cog, name="Games"):
def __init__(self, bot):
self.bot = bot
@commands.command(name="gamesuggest", description="Suggest game ideas.")
async def _gamesuggest(self, ctx):
await ctx.send(f"Use the **{config.prefix}devmsg** command to send the suggestions.")
def setup(bot):
bot.add_cog(Games(bot))
|
1681821
|
from indicnlp.tokenize import indic_detokenize
indic_string='" सुनो , कुछ आवाज़ आ रही है . " , उसने कहा । '
print('Input String: {}'.format(indic_string))
print('Detokenized String: {}'.format(indic_detokenize.trivial_detokenize(indic_string,lang='hi')))
|
1681824
|
def insertion_sort(nums):
# Start on the second element as we assume the first element is sorted
for i in range(1, len(nums)):
item_to_insert = nums[i]
# And keep a reference of the index of the previous element
j = i - 1
# Move all items of the sorted segment forward if they are larger than
# the item to insert
while j >= 0 and nums[j] > item_to_insert:
nums[j + 1] = nums[j]
j -= 1
# Insert the item
nums[j + 1] = item_to_insert
# Verify it works
random_list_of_nums = [9, 1, 15, 28, 6]
insertion_sort(random_list_of_nums)
print(random_list_of_nums)
|
1681842
|
import flask
import requests
import os
from urllib.parse import urlparse, parse_qs
import json
app = flask.Flask(__name__)
app.config["DEBUG"] = True # TODO: make production
buildkite_api_token = os.getenv("BUILDKITE_API_TOKEN", "")
@app.route('/', methods=['GET'])
def home():
return "Hi LLVM!"
@app.route('/build', methods=['POST', 'GET'])
def build():
app.logger.info('request: %s %s', flask.request, flask.request.url)
app.logger.info('headers: %s', flask.request.headers)
if flask.request.method == 'POST':
app.logger.info('data: %s', flask.request.data)
app.logger.info('form: %s', flask.request.form)
url = urlparse(flask.request.url)
params = parse_qs(url.query)
build_env = {}
for k, v in params.items():
if len(v) == 1:
build_env['ph_' + k] = v[0]
refspec = 'main'
if 'ph_scripts_refspec' in build_env:
refspec = build_env['ph_scripts_refspec']
build_request = {
'commit': 'HEAD',
'branch': refspec,
'env': build_env,
'message': f'D{build_env["ph_buildable_revision"]}',
}
app.logger.info('buildkite request: %s', build_request)
headers = {'Authorization': f'Bearer {buildkite_api_token}'}
response = requests.post(
'https://api.buildkite.com/v2/organizations/llvm-project'
'/pipelines/diff-checks/builds',
json=build_request,
headers=headers)
app.logger.info('buildkite response: %s %s', response.status_code, response.text)
rjs = json.loads(response.text)
return rjs['web_url']
else:
return "expected POST request"
if __name__ == '__main__':
app.run(host='0.0.0.0:8080')
|
1681866
|
import numpy as np
import torch
import torch.nn as nn
import torch.nn.functional as F
def norm_col_init(weights, std=1.0):
x = torch.randn(weights.size())
x *= std / torch.sqrt((x**2).sum(1, keepdim=True))
return x
def weights_init(m):
classname = m.__class__.__name__
if classname.find('Conv') != -1:
weight_shape = list(m.weight.data.size())
fan_in = np.prod(weight_shape[1:4])
fan_out = np.prod(weight_shape[2:4]) * weight_shape[0]
w_bound = np.sqrt(6. / (fan_in + fan_out))
m.weight.data.uniform_(-w_bound, w_bound)
m.bias.data.fill_(0)
elif classname.find('Linear') != -1:
weight_shape = list(m.weight.data.size())
fan_in = weight_shape[1]
fan_out = weight_shape[0]
w_bound = np.sqrt(6. / (fan_in + fan_out))
m.weight.data.uniform_(-w_bound, w_bound)
m.bias.data.fill_(0)
class A3Clstm(torch.nn.Module):
def __init__(self, num_inputs, action_space):
super(A3Clstm, self).__init__()
# convolutional neural networks
self.conv1 = nn.Conv2d(num_inputs, 32, 5, stride=1, padding=2)
self.maxp1 = nn.MaxPool2d(2, 2)
self.conv2 = nn.Conv2d(32, 32, 5, stride=1, padding=1)
self.maxp2 = nn.MaxPool2d(2, 2)
self.conv3 = nn.Conv2d(32, 64, 4, stride=1, padding=1)
self.maxp3 = nn.MaxPool2d(2, 2)
self.conv4 = nn.Conv2d(64, 64, 3, stride=1, padding=1)
self.maxp4 = nn.MaxPool2d(2, 2)
# LSTM Cells
self.lstm = nn.LSTMCell(1024, 512)
num_outputs = action_space.n
# The critic layer
self.critic_linear = nn.Linear(512, 1)
# The actor layer
self.actor_linear = nn.Linear(512, num_outputs)
self.apply(weights_init)
self.actor_linear.weight.data = norm_col_init(
self.actor_linear.weight.data, 0.01)
self.actor_linear.bias.data.fill_(0)
self.critic_linear.weight.data = norm_col_init(
self.critic_linear.weight.data, 1.0)
self.critic_linear.bias.data.fill_(0)
self.lstm.bias_ih.data.fill_(0)
self.lstm.bias_hh.data.fill_(0)
self.train()
# forward propagation
def forward(self, inputs):
inputs, (hx, cx) = inputs
x = F.relu(self.maxp1(self.conv1(inputs)))
x = F.relu(self.maxp2(self.conv2(x)))
x = F.relu(self.maxp3(self.conv3(x)))
x = F.relu(self.maxp4(self.conv4(x)))
x = x.view(x.size(0), -1)
hx, cx = self.lstm(x, (hx, cx))
x = hx
return self.critic_linear(x), self.actor_linear(x), (hx, cx)
|
1681917
|
from BaseComponents.Buttons import Button
from SettingComponents.Layouts.ScrollArea import ScrollArea
def get_arearect(settings):
area_width = settings.default_width
area_height = settings.default_height
middle_x = settings.default_x + settings.default_width/2
middle_y = settings.default_y + settings.default_height/2
return 0, 0, area_width, area_height
class SettingsPage(Button):
def __init__(self, parent):
super(SettingsPage, self).__init__(parent)
self.default_x = 20
self.default_y = 20
self.default_size = 4
self.img_idle = "res/WindowShadow.png"
self.img_hover = "res/WindowShadow.png"
self.img_click = "res/WindowShadow.png"
super().setup()
self.settingsarea = ScrollArea(self, parent)
self.hide()
self.load_settings()
def changesize(self):
super().changesize()
self.settingsarea.changesize()
def load_settings(self):
self.settingsarea.load_settings()
def reload_settings(self):
self.settingsarea.reload_settings()
def updatevalue(self):
self.settingsarea.gridLayout.updatevalue()
|
1681924
|
import argparse
from util.torch_util import str_to_bool
class ArgumentParser():
def __init__(self,mode='train'):
self.parser = argparse.ArgumentParser(description='CNNGeometric PyTorch implementation')
self.add_cnn_model_parameters()
if mode=='train':
self.add_train_parameters()
self.add_synth_dataset_parameters()
self.add_base_train_parameters()
elif mode=='eval':
self.add_eval_parameters()
self.add_base_eval_parameters()
def add_cnn_model_parameters(self):
model_params = self.parser.add_argument_group('model')
# Model parameters
model_params.add_argument('--feature-extraction-cnn', type=str, default='vgg', help='feature extraction CNN model architecture: vgg/resnet101')
model_params.add_argument('--feature-extraction-last-layer', type=str, default='', help='feature extraction CNN last layer')
model_params.add_argument('--fr-kernel-sizes', nargs='+', type=int, default=[7,5,5], help='kernels sizes in feat.reg. conv layers')
model_params.add_argument('--fr-channels', nargs='+', type=int, default=[225,128,64], help='channels in feat. reg. conv layers')
model_params.add_argument('--matching-type', type=str, default='correlation', help='correlation/subtraction/concatenation')
model_params.add_argument('--normalize-matches', type=str_to_bool, nargs='?', const=True, default=True, help='perform L2 normalization')
def add_base_train_parameters(self):
base_params = self.parser.add_argument_group('base')
# Image size
base_params.add_argument('--image-size', type=int, default=240, help='image input size')
# Pre-trained model file
base_params.add_argument('--model', type=str, default='', help='Pre-trained model filename')
base_params.add_argument('--num-workers', type=int, default=4, help='number of workers')
def add_base_eval_parameters(self):
base_params = self.parser.add_argument_group('base')
# Image size
base_params.add_argument('--image-size', type=int, default=240, help='image input size')
# Pre-trained model file
base_params.add_argument('--model-1', type=str, default='', help='Trained model - stage 1')
base_params.add_argument('--model-2', type=str, default='', help='Trained model - stage 2')
# Number of stages
base_params.add_argument('--num-of-iters', type=int, default=1, help='number of stages to use recursively')
def add_synth_dataset_parameters(self):
dataset_params = self.parser.add_argument_group('dataset')
# Dataset parameters
dataset_params.add_argument('--dataset-csv-path', type=str, default='', help='path to training transformation csv folder')
dataset_params.add_argument('--dataset-image-path', type=str, default='', help='path to folder containing training images')
# Random synth dataset parameters
dataset_params.add_argument('--four-point-hom', type=str_to_bool, nargs='?', const=True, default=True, help='use 4 pt parametrization for homography')
dataset_params.add_argument('--random-sample', type=str_to_bool, nargs='?', const=True, default=True, help='sample random transformations')
dataset_params.add_argument('--random-t', type=float, default=0.5, help='random transformation translation')
dataset_params.add_argument('--random-s', type=float, default=0.5, help='random transformation translation')
dataset_params.add_argument('--random-alpha', type=float, default=1/6, help='random transformation translation')
dataset_params.add_argument('--random-t-tps', type=float, default=0.4, help='random transformation translation')
def add_train_parameters(self):
train_params = self.parser.add_argument_group('train')
# Optimization parameters
train_params.add_argument('--lr', type=float, default=0.001, help='learning rate')
train_params.add_argument('--lr_scheduler', type=str_to_bool,
nargs='?', const=True, default=True,
help='Bool (default True), whether to use a decaying lr_scheduler')
train_params.add_argument('--lr_max_iter', type=int, default=1000,
help='Number of steps between lr starting value and 1e-6 '
'(lr default min) when choosing lr_scheduler')
train_params.add_argument('--momentum', type=float, default=0.9, help='momentum constant')
train_params.add_argument('--num-epochs', type=int, default=20, help='number of training epochs')
train_params.add_argument('--batch-size', type=int, default=16, help='training batch size')
train_params.add_argument('--weight-decay', type=float, default=0, help='weight decay constant')
train_params.add_argument('--seed', type=int, default=1, help='Pseudo-RNG seed')
train_params.add_argument('--use-mse-loss', type=str_to_bool, nargs='?', const=True, default=False, help='Use MSE loss on tnf. parameters')
train_params.add_argument('--geometric-model', type=str, default='affine', help='affine/hom/tps')
# Trained model parameters
train_params.add_argument('--trained-model-fn', type=str, default='checkpoint_adam', help='trained model filename')
train_params.add_argument('--trained-model-dir', type=str, default='trained_models', help='path to trained models folder')
# Dataset name (used for loading defaults)
train_params.add_argument('--training-dataset', type=str, default='pascal', help='dataset to use for training')
# Limit train/test dataset sizes
train_params.add_argument('--train-dataset-size', type=int, default=0, help='train dataset size limit')
train_params.add_argument('--test-dataset-size', type=int, default=0, help='test dataset size limit')
# Parts of model to train
train_params.add_argument('--train-fe', type=str_to_bool, nargs='?', const=True, default=True, help='Train feature extraction')
train_params.add_argument('--train-fr', type=str_to_bool, nargs='?', const=True, default=True, help='Train feature regressor')
train_params.add_argument('--train-bn', type=str_to_bool, nargs='?', const=True, default=True, help='train batch-norm layers')
train_params.add_argument('--fe-finetune-params', nargs='+', type=str, default=[''], help='String indicating the F.Ext params to finetune')
train_params.add_argument('--update-bn-buffers', type=str_to_bool, nargs='?', const=True, default=False, help='Update batch norm running mean and std')
# Train with occlusion
train_params.add_argument('--occlusion-factor', type=float, default=0, help='occlusion factor for training')
# log parameters
train_params.add_argument('--log_interval', type=int, default=100,
help='Number of iterations between logs')
train_params.add_argument('--log_dir', type=str, default='',
help='If unspecified log_dir will be set to'
'<trained_models_dir>/<trained_models_fn>/')
def add_eval_parameters(self):
eval_params = self.parser.add_argument_group('eval')
# Evaluation parameters
eval_params.add_argument('--eval-dataset', type=str, default='pf', help='pf/caltech/tss')
eval_params.add_argument('--eval-dataset-path', type=str, default='', help='Path to PF dataset')
eval_params.add_argument('--flow-output-dir', type=str, default='results/', help='flow output dir')
eval_params.add_argument('--pck-alpha', type=float, default=0.1, help='pck margin factor alpha')
eval_params.add_argument('--eval-metric', type=str, default='pck', help='pck/distance')
eval_params.add_argument('--tps-reg-factor', type=float, default=0.0, help='regularisation factor for tps tnf')
eval_params.add_argument('--batch-size', type=int, default=16, help='batch size (only GPU)')
def parse(self,arg_str=None):
if arg_str is None:
args = self.parser.parse_args()
else:
args = self.parser.parse_args(arg_str.split())
arg_groups = {}
for group in self.parser._action_groups:
group_dict={a.dest:getattr(args,a.dest,None) for a in group._group_actions}
arg_groups[group.title]=group_dict
return (args,arg_groups)
|
1681935
|
import json
import logging
import splunk.admin as admin
import splunk.rest as rest
import log_helper
# Setup the handler
logger = log_helper.setup(logging.INFO, 'BaseEAIHandler', 'base_handler.log')
class BaseEAIHandler(admin.MConfigHandler):
def get_param(self, param, default=None):
"""
Returns value of a matched param from either POST or GET encoded values.
Note: Returns the first entry as a param - can be multi-valued.
Arguments
param -- The param key to extract.
"""
if param in self.callerArgs:
if self.callerArgs[param][0] is not None:
return self.callerArgs[param][0].strip()
return default
def get_params(self, schema, filter=None):
"""
Returns a flattened dictionary of key/value pairs of posted allowable params.
The EAI Admin Handler plucks name out and sets it the id instance member. This
adds the name key back to the params dictionary returned.
Arguments
filter -- (default None) An optional array of param keys to extract in dictionary
This is useful to bypass a wholesale dump.
"""
params = {}
for param in schema.ALL_FIELDS:
if param in self.callerArgs and (filter is None or param in filter):
param_value = self.callerArgs[param][0]
if param_value is not None:
params[param] = param_value.strip()
if filter is None or 'name' in filter:
params['name'] = self.callerArgs.id.strip()
return params
def validate_params(self, schema, params):
"""
Returns validated params key/value pair dictionary using predefined schema that casts objects to python types.
Arguments
schema -- Schema object (see schema module).
param_names -- (Optional) Parameters to filter out for validation.
"""
try:
params = schema.validate(params)
except Exception as e:
logger.error(e)
error_message = str(e).replace('Missing keys:', 'Missing field(s):')
raise admin.InternalException(error_message)
return params
def simple_request_messages_to_str(self, messages):
"""
Returns a readable string from a simple request response message
Arguments
messages -- The simple request response message to parse
"""
entries = []
for message in messages:
entries.append(message.get('text'))
return ','.join(entries)
def set_conf_info_from_eai_payload(self, confInfo, payload):
"""
Takes the mutable confInfo object and sets the content to that found from
the list of entry content children.
Arguments
confInfo -- The object containing the information about what is being requested.
payload -- Parsed EAI response from an EAI output_mode=json response.
"""
entries = payload.get('entry', [])
for entry in entries:
entry_name = entry.get('name')
entry_content = entry.get('content')
for entry_content_key in entry_content:
confInfo[entry_name][entry_content_key] = entry_content.get(entry_content_key)
return confInfo
def get_conf_handler_path_name(self, conf_file_name, user='nobody', app=None):
"""
Returns the generic conf file REST handler path from the provided arguments
Arguments
conf_file_name -- The conf file to use in the returned the handler path.
payload (optional) -- The user namespace to use in the returned the handler path. Default is 'nobody'
"""
if app is None:
app = self.appName
return '/servicesNS/%s/%s/configs/conf-%s' % (user, app, conf_file_name)
def simple_request_eai(self, url, action, method, params=None, get_args=None):
"""
Returns the payload response from a simpleRequest call
Arguments
url -- The REST handler endpoint to use in the simpleRequest
params -- The parameters sent in the POST body of the simpleRequest
"""
if not params:
params = {}
default_get_args = dict(output_mode='json')
if get_args:
default_get_args.update(get_args)
logger.info('%s request %s' % (method, url))
try:
response, content = rest.simpleRequest(url, getargs=default_get_args, postargs=params,
method=method, sessionKey=self.getSessionKey())
except Exception as e:
logger.error(e)
raise admin.ServiceUnavailableException('Unable to %s %s entry.' % (action, url))
try:
payload = json.loads(content)
except Exception as e:
logger.error(e)
raise admin.InternalException('Unable to parse %s response payload.' % url)
if response.status not in [200, 201]:
message = self.simple_request_messages_to_str(response.messages)
logger.error(
'handler_message="request failed, status code not in successful range" status="%s" params="%s" splunkd_message="%s"' % (
response.status, params, message))
raise admin.AlreadyExistsException(
'Unable to %s %s entry. %s' % (action, url, message))
return payload
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.