SYMBOL INDEX (364 symbols across 19 files) FILE: EMA.py class EMA (line 17) | class EMA(Optimizer): method __init__ (line 18) | def __init__(self, opt, ema_decay): method step (line 25) | def step(self, *args, **kwargs): method load_state_dict (line 64) | def load_state_dict(self, state_dict): method swap_parameters_with_ema (line 71) | def swap_parameters_with_ema(self, store_params_in_ema): FILE: blur_diffusion.py function gaussian_kernel_1d (line 10) | def gaussian_kernel_1d(kernel_size, sigma): function betas_for_alpha_bar (line 22) | def betas_for_alpha_bar(num_diffusion_timesteps, alpha_bar, max_beta=0.9... class ExpSchedule (line 34) | class ExpSchedule: method __init__ (line 35) | def __init__(self, N, offset = 1e-4): method get_betas (line 45) | def get_betas(self): class ForwardBlurIncreasing (line 51) | class ForwardBlurIncreasing: method __init__ (line 52) | def __init__(self, N, beta_min, beta_max, sig, sig_min, sig_max, D_dia... method _beta_i (line 184) | def _beta_i(self, i): method _alpha_i (line 187) | def _alpha_i(self, i): method _alphas_bar_i (line 190) | def _alphas_bar_i(self, i): method _Bhat_i (line 193) | def _Bhat_i(self, i): method _Bhat_sq_i (line 197) | def _Bhat_sq_i(self, i): method get_mean (line 204) | def get_mean(self, x0, i): method get_std (line 210) | def get_std(self,i, noise): method get_var (line 216) | def get_var(self, x0, i, noise=None): method W (line 223) | def W(self, x, i): method W_inv (line 233) | def W_inv(self, x, i): method U_I_minus_B_Ut (line 241) | def U_I_minus_B_Ut(self, x, i): # U(I-B)UT method U_I_minus_B_sqrt_Ut (line 250) | def U_I_minus_B_sqrt_Ut(self, x, i): # U(sqrt(I-B))UT method get_x_i (line 260) | def get_x_i(self, x0, i, return_eps = False): method get_x_N (line 284) | def get_x_N(self, x0_shape, N): method get_x0_from_eps (line 308) | def get_x0_from_eps(self, xi, eps, i): method get_score_gt (line 323) | def get_score_gt(self, xi, x0, i): method get_score_gt2 (line 341) | def get_score_gt2(self, xi, x0, i): method sanity (line 360) | def sanity(self, x_0, i): method get_score_from_eps (line 402) | def get_score_from_eps(self, eps, i): method get_score_from_std (line 409) | def get_score_from_std(self, std, i): method get_loss_i_exact (line 415) | def get_loss_i_exact(self, model, x0, xi, i): method get_loss_i_simple (line 423) | def get_loss_i_simple(self, model, x0, xi, i): method get_loss_i_eps_simple (line 444) | def get_loss_i_eps_simple(self, model, x_i, i, eps): method get_loss_i_std_matching (line 448) | def get_loss_i_std_matching(self, model, x_i, i, eps): class H_functions (line 458) | class H_functions: method V (line 466) | def V(self, vec): method Vt (line 472) | def Vt(self, vec): method U (line 478) | def U(self, vec): method Ut (line 484) | def Ut(self, vec): method singulars (line 490) | def singulars(self): method add_zeros (line 496) | def add_zeros(self, vec): method H (line 502) | def H(self, vec): method Ht (line 510) | def Ht(self, vec): method H_pinv (line 518) | def H_pinv(self, vec): class Deblurring (line 528) | class Deblurring(H_functions): method mat_by_img (line 529) | def mat_by_img(self, M, v): method img_by_mat (line 533) | def img_by_mat(self, v, M): method __init__ (line 537) | def __init__(self, kernel, channels, img_dim, device): method V (line 564) | def V(self, vec): method Vt (line 574) | def Vt(self, vec): method U (line 582) | def U(self, vec): method Ut (line 592) | def Ut(self, vec): method conv1d_col_matmul (line 600) | def conv1d_col_matmul(self, x): method conv1d_row_matmul (line 603) | def conv1d_row_matmul(self, x): method conv2d_sep_matmul (line 606) | def conv2d_sep_matmul(self, x): method singulars (line 609) | def singulars(self): method update_singulars (line 615) | def update_singulars(self, new_singulars): method add_zeros (line 618) | def add_zeros(self, vec): FILE: fid.py class FID (line 4) | class FID(object): method __init__ (line 5) | def __init__(self, real_dir, device, bsize = 128): method __call__ (line 20) | def __call__(self, fake_dir): FILE: guided_diffusion/dist_util.py function setup_dist (line 21) | def setup_dist(): function dev (line 51) | def dev(): function load_state_dict (line 60) | def load_state_dict(path, **kwargs): function sync_params (line 83) | def sync_params(params): function _find_free_port (line 92) | def _find_free_port(): FILE: guided_diffusion/fp16_util.py function convert_module_to_f16 (line 15) | def convert_module_to_f16(l): function convert_module_to_f32 (line 25) | def convert_module_to_f32(l): function make_master_params (line 35) | def make_master_params(param_groups_and_shapes): function model_grads_to_master_grads (line 52) | def model_grads_to_master_grads(param_groups_and_shapes, master_params): function master_params_to_model_params (line 65) | def master_params_to_model_params(param_groups_and_shapes, master_params): function unflatten_master_params (line 78) | def unflatten_master_params(param_group, master_param): function get_param_groups_and_shapes (line 82) | def get_param_groups_and_shapes(named_model_params): function master_params_to_state_dict (line 95) | def master_params_to_state_dict( function state_dict_to_master_params (line 116) | def state_dict_to_master_params(model, state_dict, use_fp16): function zero_master_grads (line 128) | def zero_master_grads(master_params): function zero_grad (line 133) | def zero_grad(model_params): function param_grad_or_zeros (line 141) | def param_grad_or_zeros(param): class MixedPrecisionTrainer (line 148) | class MixedPrecisionTrainer: method __init__ (line 149) | def __init__( method zero_grad (line 173) | def zero_grad(self): method backward (line 176) | def backward(self, loss: th.Tensor): method optimize (line 183) | def optimize(self, opt: th.optim.Optimizer): method _optimize_fp16 (line 189) | def _optimize_fp16(self, opt: th.optim.Optimizer): method _optimize_normal (line 209) | def _optimize_normal(self, opt: th.optim.Optimizer): method _compute_norms (line 216) | def _compute_norms(self, grad_scale=1.0): method master_params_to_state_dict (line 226) | def master_params_to_state_dict(self, master_params): method state_dict_to_master_params (line 231) | def state_dict_to_master_params(self, state_dict): function check_overflow (line 235) | def check_overflow(value): FILE: guided_diffusion/gaussian_diffusion.py function get_named_beta_schedule (line 18) | def get_named_beta_schedule(schedule_name, num_diffusion_timesteps): function betas_for_alpha_bar (line 45) | def betas_for_alpha_bar(num_diffusion_timesteps, alpha_bar, max_beta=0.9... class ModelMeanType (line 65) | class ModelMeanType(enum.Enum): class ModelVarType (line 75) | class ModelVarType(enum.Enum): class LossType (line 89) | class LossType(enum.Enum): method is_vb (line 97) | def is_vb(self): class GaussianDiffusion (line 101) | class GaussianDiffusion: method __init__ (line 118) | def __init__( method q_mean_variance (line 171) | def q_mean_variance(self, x_start, t): method q_sample (line 188) | def q_sample(self, x_start, t, noise=None): method q_sample_blur (line 208) | def q_sample_blur(self, x_start, t, noise=None): method q_posterior_mean_variance (line 226) | def q_posterior_mean_variance(self, x_start, x_t, t): method p_mean_variance (line 250) | def p_mean_variance( method _predict_xstart_from_eps (line 346) | def _predict_xstart_from_eps(self, x_t, t, eps): method _predict_xstart_from_xprev (line 353) | def _predict_xstart_from_xprev(self, x_t, t, xprev): method _predict_eps_from_xstart (line 363) | def _predict_eps_from_xstart(self, x_t, t, pred_xstart): method _scale_timesteps (line 369) | def _scale_timesteps(self, t): method condition_mean (line 374) | def condition_mean(self, cond_fn, p_mean_var, x, t, model_kwargs=None): method condition_score (line 389) | def condition_score(self, cond_fn, p_mean_var, x, t, model_kwargs=None): method p_sample (line 412) | def p_sample( method p_sample_blur (line 458) | def p_sample_blur( method p_sample_loop (line 506) | def p_sample_loop( method p_sample_loop_progressive (line 557) | def p_sample_loop_progressive( method ddim_sample (line 610) | def ddim_sample( method ddim_reverse_sample (line 660) | def ddim_reverse_sample( method ddim_sample_loop (line 698) | def ddim_sample_loop( method ddim_sample_loop_progressive (line 732) | def ddim_sample_loop_progressive( method _vb_terms_bpd (line 782) | def _vb_terms_bpd( method training_losses (line 817) | def training_losses(self, model, x_start, t, model_kwargs=None, noise=... method _prior_bpd (line 897) | def _prior_bpd(self, x_start): method calc_bpd_loop (line 915) | def calc_bpd_loop(self, model, x_start, clip_denoised=True, model_kwar... function _extract_into_tensor (line 998) | def _extract_into_tensor(arr, timesteps, broadcast_shape): function tensor2pil (line 1013) | def tensor2pil(t): function denorm (line 1016) | def denorm(t): function tensor_imsave (line 1019) | def tensor_imsave(t, path, fname, denormalization=True, prt=False): function pil_loader (line 1028) | def pil_loader(path): function check_folder (line 1033) | def check_folder(log_dir): FILE: guided_diffusion/image_datasets.py function load_data (line 11) | def load_data( function _list_image_files_recursively (line 70) | def _list_image_files_recursively(data_dir): class ImageDataset (line 82) | class ImageDataset(Dataset): method __init__ (line 83) | def __init__( method __len__ (line 100) | def __len__(self): method __getitem__ (line 103) | def __getitem__(self, idx): function center_crop_arr (line 126) | def center_crop_arr(pil_image, image_size): function random_crop_arr (line 146) | def random_crop_arr(pil_image, image_size, min_crop_frac=0.8, max_crop_f... FILE: guided_diffusion/logger.py class KVWriter (line 26) | class KVWriter(object): method writekvs (line 27) | def writekvs(self, kvs): class SeqWriter (line 31) | class SeqWriter(object): method writeseq (line 32) | def writeseq(self, seq): class HumanOutputFormat (line 36) | class HumanOutputFormat(KVWriter, SeqWriter): method __init__ (line 37) | def __init__(self, filename_or_file): method writekvs (line 48) | def writekvs(self, kvs): method _truncate (line 80) | def _truncate(self, s): method writeseq (line 84) | def writeseq(self, seq): method close (line 93) | def close(self): class JSONOutputFormat (line 98) | class JSONOutputFormat(KVWriter): method __init__ (line 99) | def __init__(self, filename): method writekvs (line 102) | def writekvs(self, kvs): method close (line 109) | def close(self): class CSVOutputFormat (line 113) | class CSVOutputFormat(KVWriter): method __init__ (line 114) | def __init__(self, filename): method writekvs (line 119) | def writekvs(self, kvs): method close (line 146) | def close(self): class TensorBoardOutputFormat (line 150) | class TensorBoardOutputFormat(KVWriter): method __init__ (line 155) | def __init__(self, dir): method writekvs (line 171) | def writekvs(self, kvs): method close (line 185) | def close(self): function make_output_format (line 191) | def make_output_format(format, ev_dir, log_suffix=""): function logkv (line 212) | def logkv(key, val): function logkv_mean (line 221) | def logkv_mean(key, val): function logkvs (line 228) | def logkvs(d): function dumpkvs (line 236) | def dumpkvs(): function getkvs (line 243) | def getkvs(): function log (line 247) | def log(*args, level=INFO): function debug (line 254) | def debug(*args): function info (line 258) | def info(*args): function warn (line 262) | def warn(*args): function error (line 266) | def error(*args): function set_level (line 270) | def set_level(level): function set_comm (line 277) | def set_comm(comm): function get_dir (line 281) | def get_dir(): function profile_kv (line 294) | def profile_kv(scopename): function profile (line 303) | def profile(n): function get_current (line 325) | def get_current(): class Logger (line 332) | class Logger(object): method __init__ (line 337) | def __init__(self, dir, output_formats, comm=None): method logkv (line 347) | def logkv(self, key, val): method logkv_mean (line 350) | def logkv_mean(self, key, val): method dumpkvs (line 355) | def dumpkvs(self): method log (line 376) | def log(self, *args, level=INFO): method set_level (line 382) | def set_level(self, level): method set_comm (line 385) | def set_comm(self, comm): method get_dir (line 388) | def get_dir(self): method close (line 391) | def close(self): method _do_log (line 397) | def _do_log(self, args): function get_rank_without_mpi_import (line 403) | def get_rank_without_mpi_import(): function mpi_weighted_mean (line 412) | def mpi_weighted_mean(comm, local_name2valcount): function configure (line 442) | def configure(dir=None, format_strs=None, comm=None, log_suffix=""): function _configure_default_logger (line 475) | def _configure_default_logger(): function reset (line 480) | def reset(): function scoped_configure (line 488) | def scoped_configure(dir=None, format_strs=None, comm=None): FILE: guided_diffusion/losses.py function normal_kl (line 12) | def normal_kl(mean1, logvar1, mean2, logvar2): function approx_standard_normal_cdf (line 42) | def approx_standard_normal_cdf(x): function discretized_gaussian_log_likelihood (line 50) | def discretized_gaussian_log_likelihood(x, *, means, log_scales): FILE: guided_diffusion/nn.py class SiLU (line 12) | class SiLU(nn.Module): method forward (line 13) | def forward(self, x): class GroupNorm32 (line 17) | class GroupNorm32(nn.GroupNorm): method forward (line 18) | def forward(self, x): function conv_nd (line 22) | def conv_nd(dims, *args, **kwargs): function linear (line 35) | def linear(*args, **kwargs): function avg_pool_nd (line 42) | def avg_pool_nd(dims, *args, **kwargs): function update_ema (line 55) | def update_ema(target_params, source_params, rate=0.99): function zero_module (line 68) | def zero_module(module): function scale_module (line 77) | def scale_module(module, scale): function mean_flat (line 86) | def mean_flat(tensor): function normalization (line 93) | def normalization(channels): function timestep_embedding (line 103) | def timestep_embedding(timesteps, dim, max_period=10000): function checkpoint (line 124) | def checkpoint(func, inputs, params, flag): class CheckpointFunction (line 142) | class CheckpointFunction(th.autograd.Function): method forward (line 144) | def forward(ctx, run_function, length, *args): method backward (line 153) | def backward(ctx, *output_grads): FILE: guided_diffusion/resample.py function create_named_schedule_sampler (line 8) | def create_named_schedule_sampler(name, diffusion): class ScheduleSampler (line 23) | class ScheduleSampler(ABC): method weights (line 35) | def weights(self): method sample (line 42) | def sample(self, batch_size, device): class UniformSampler (line 64) | class UniformSampler(ScheduleSampler): method __init__ (line 65) | def __init__(self, diffusion): method weights (line 69) | def weights(self): class LossAwareSampler (line 73) | class LossAwareSampler(ScheduleSampler): method update_with_local_losses (line 74) | def update_with_local_losses(self, local_ts, local_losses): method update_with_all_losses (line 110) | def update_with_all_losses(self, ts, losses): class LossSecondMomentResampler (line 127) | class LossSecondMomentResampler(LossAwareSampler): method __init__ (line 128) | def __init__(self, diffusion, history_per_term=10, uniform_prob=0.001): method weights (line 138) | def weights(self): method update_with_all_losses (line 147) | def update_with_all_losses(self, ts, losses): method _warmed_up (line 157) | def _warmed_up(self): FILE: guided_diffusion/respace.py function space_timesteps (line 7) | def space_timesteps(num_timesteps, section_counts): class SpacedDiffusion (line 63) | class SpacedDiffusion(GaussianDiffusion): method __init__ (line 72) | def __init__(self, use_timesteps, **kwargs): method p_mean_variance (line 88) | def p_mean_variance( method training_losses (line 93) | def training_losses( method condition_mean (line 98) | def condition_mean(self, cond_fn, *args, **kwargs): method condition_score (line 101) | def condition_score(self, cond_fn, *args, **kwargs): method _wrap_model (line 104) | def _wrap_model(self, model): method _scale_timesteps (line 111) | def _scale_timesteps(self, t): class _WrappedModel (line 116) | class _WrappedModel: method __init__ (line 117) | def __init__(self, model, timestep_map, rescale_timesteps, original_nu... method __call__ (line 123) | def __call__(self, x, ts, **kwargs): FILE: guided_diffusion/script_util.py function diffusion_defaults (line 11) | def diffusion_defaults(): function classifier_defaults (line 27) | def classifier_defaults(): function model_and_diffusion_defaults (line 43) | def model_and_diffusion_defaults(): function classifier_and_diffusion_defaults (line 68) | def classifier_and_diffusion_defaults(): function create_model_and_diffusion (line 74) | def create_model_and_diffusion( function create_model (line 130) | def create_model( function create_classifier_and_diffusion (line 187) | def create_classifier_and_diffusion( function create_classifier (line 228) | def create_classifier( function sr_model_and_diffusion_defaults (line 269) | def sr_model_and_diffusion_defaults(): function sr_create_model_and_diffusion (line 280) | def sr_create_model_and_diffusion( function sr_create_model (line 334) | def sr_create_model( function create_gaussian_diffusion (line 386) | def create_gaussian_diffusion( function add_dict_to_argparser (line 427) | def add_dict_to_argparser(parser, default_dict): function args_to_dict (line 437) | def args_to_dict(args, keys): function str2bool (line 441) | def str2bool(v): FILE: guided_diffusion/train_util.py class TrainLoop (line 22) | class TrainLoop: method __init__ (line 23) | def __init__( method _load_and_sync_parameters (line 110) | def _load_and_sync_parameters(self): method _load_ema_parameters (line 125) | def _load_ema_parameters(self, rate): method _load_optimizer_state (line 141) | def _load_optimizer_state(self): method run_loop (line 153) | def run_loop(self): method run_step (line 172) | def run_step(self, batch, cond): method forward_backward (line 180) | def forward_backward(self, batch, cond): method _update_ema (line 217) | def _update_ema(self): method _anneal_lr (line 221) | def _anneal_lr(self): method log_step (line 229) | def log_step(self): method save (line 233) | def save(self): function parse_resume_step_from_filename (line 259) | def parse_resume_step_from_filename(filename): function get_blob_logdir (line 274) | def get_blob_logdir(): function find_resume_checkpoint (line 280) | def find_resume_checkpoint(): function find_ema_checkpoint (line 286) | def find_ema_checkpoint(main_checkpoint, step, rate): function log_loss_dict (line 296) | def log_loss_dict(diffusion, ts, losses): FILE: guided_diffusion/unet.py class AttentionPool2d (line 22) | class AttentionPool2d(nn.Module): method __init__ (line 27) | def __init__( method forward (line 43) | def forward(self, x): class TimestepBlock (line 54) | class TimestepBlock(nn.Module): method forward (line 60) | def forward(self, x, emb): class TimestepEmbedSequential (line 66) | class TimestepEmbedSequential(nn.Sequential, TimestepBlock): method forward (line 72) | def forward(self, x, emb): class Upsample (line 81) | class Upsample(nn.Module): method __init__ (line 91) | def __init__(self, channels, use_conv, dims=2, out_channels=None): method forward (line 100) | def forward(self, x): class Downsample (line 113) | class Downsample(nn.Module): method __init__ (line 123) | def __init__(self, channels, use_conv, dims=2, out_channels=None): method forward (line 138) | def forward(self, x): class ResBlock (line 143) | class ResBlock(TimestepBlock): method __init__ (line 160) | def __init__( method forward (line 224) | def forward(self, x, emb): method _forward (line 236) | def _forward(self, x, emb): class AttentionBlock (line 259) | class AttentionBlock(nn.Module): method __init__ (line 267) | def __init__( method forward (line 296) | def forward(self, x): method _forward (line 299) | def _forward(self, x): function count_flops_attn (line 308) | def count_flops_attn(model, _x, y): class QKVAttentionLegacy (line 328) | class QKVAttentionLegacy(nn.Module): method __init__ (line 333) | def __init__(self, n_heads): method forward (line 337) | def forward(self, qkv): method count_flops (line 357) | def count_flops(model, _x, y): class QKVAttention (line 361) | class QKVAttention(nn.Module): method __init__ (line 366) | def __init__(self, n_heads): method forward (line 370) | def forward(self, qkv): method count_flops (line 392) | def count_flops(model, _x, y): class UNetModel (line 396) | class UNetModel(nn.Module): method __init__ (line 427) | def __init__( method convert_to_fp16 (line 631) | def convert_to_fp16(self): method convert_to_fp32 (line 639) | def convert_to_fp32(self): method forward (line 647) | def forward(self, x, timesteps, y=None): class SuperResModel (line 684) | class SuperResModel(UNetModel): method __init__ (line 691) | def __init__(self, image_size, in_channels, *args, **kwargs): method forward (line 694) | def forward(self, x, timesteps, low_res=None, **kwargs): class EncoderUNetModel (line 701) | class EncoderUNetModel(nn.Module): method __init__ (line 708) | def __init__( method convert_to_fp16 (line 875) | def convert_to_fp16(self): method convert_to_fp32 (line 882) | def convert_to_fp32(self): method forward (line 889) | def forward(self, x, timesteps): FILE: main.py function to_flattened_numpy (line 306) | def to_flattened_numpy(x): function from_flattened_numpy (line 309) | def from_flattened_numpy(x, shape): function ode_func (line 312) | def ode_func(i, y): FILE: pytorch_fid/fid_score.py function tqdm (line 49) | def tqdm(x): class ImagePathDataset (line 77) | class ImagePathDataset(torch.utils.data.Dataset): method __init__ (line 78) | def __init__(self, files, transforms=None): method __len__ (line 82) | def __len__(self): method __getitem__ (line 85) | def __getitem__(self, i): function get_activations (line 93) | def get_activations(files, model, batch_size=50, dims=2048, device='cpu', function calculate_frechet_distance (line 152) | def calculate_frechet_distance(mu1, sigma1, mu2, sigma2, eps=1e-6): function calculate_activation_statistics (line 209) | def calculate_activation_statistics(files, model, batch_size=50, dims=2048, function compute_statistics_of_path (line 234) | def compute_statistics_of_path(path, model, batch_size, dims, device, function calculate_fid_given_paths (line 251) | def calculate_fid_given_paths(paths, batch_size, device, dims, num_worke... function main (line 270) | def main(): FILE: pytorch_fid/inception.py class InceptionV3 (line 16) | class InceptionV3(nn.Module): method __init__ (line 31) | def __init__(self, method forward (line 129) | def forward(self, inp): function _inception_v3 (line 166) | def _inception_v3(*args, **kwargs): function fid_inception_v3 (line 184) | def fid_inception_v3(): class FIDInceptionA (line 211) | class FIDInceptionA(torchvision.models.inception.InceptionA): method __init__ (line 213) | def __init__(self, in_channels, pool_features): method forward (line 216) | def forward(self, x): class FIDInceptionC (line 236) | class FIDInceptionC(torchvision.models.inception.InceptionC): method __init__ (line 238) | def __init__(self, in_channels, channels_7x7): method forward (line 241) | def forward(self, x): class FIDInceptionE_1 (line 264) | class FIDInceptionE_1(torchvision.models.inception.InceptionE): method __init__ (line 266) | def __init__(self, in_channels): method forward (line 269) | def forward(self, x): class FIDInceptionE_2 (line 297) | class FIDInceptionE_2(torchvision.models.inception.InceptionE): method __init__ (line 299) | def __init__(self, in_channels): method forward (line 302) | def forward(self, x): FILE: utils.py function tensor2pil (line 9) | def tensor2pil(t): function denorm (line 12) | def denorm(t): function tensor_imsave (line 14) | def tensor_imsave(t, path, fname, denormalization=False, prt=False): function pil_loader (line 23) | def pil_loader(path): function check_folder (line 28) | def check_folder(log_dir): function freeze_model (line 32) | def freeze_model(model): class TVLoss (line 35) | class TVLoss(nn.Module): method __init__ (line 36) | def __init__(self,TVLoss_weight=1): method forward (line 40) | def forward(self,x): method _tensor_size (line 50) | def _tensor_size(self,t): function pil_batch_loader (line 53) | def pil_batch_loader(root_path, bsize): class PSNR (line 63) | class PSNR(object): method __init__ (line 64) | def __init__(self, gpu, val_max=1, val_min=0, ycbcr=True): method __call__ (line 71) | def __call__(self,x,y): function rgb_to_ycbcr (line 92) | def rgb_to_ycbcr(image): function clear (line 118) | def clear(x): function normalize_np (line 121) | def normalize_np(x): function pad (line 126) | def pad(x, pad): function crop (line 129) | def crop(x, pad):