Creates a config file used by the embedding projector.
    Adapted from the TensorFlow function `visualize_embeddings()` at
    https://github.com/tensorflow/tensorflow/blob/master/tensorflow/contrib/tensorboard/plugins/projector/__init__.py
439198
def _add_embedding_config(file_path, data_dir, has_metadata=False, label_img_shape=None):
    """"""
    with open(os.path.join(file_path, 'projector_config.pbtxt'), 'a') as f:
        s = 'embeddings {\n'
        s += 'tensor_name: "{}"\n'.format(data_dir)
        s += 'tensor_path: "{}"\n'.format(os.path.join(data_dir, 'tensors.tsv'))
        if has_metadata:
            s += 'metadata_path: "{}"\n'.format(os.path.join(data_dir, 'metadata.tsv'))
        if label_img_shape is not None:
            if len(label_img_shape) != 4:
                logging.warning('expected 4D sprite image in the format NCHW, while received image'
                                ' ndim=%d, skipping saving sprite'
                                ' image info', len(label_img_shape))
            else:
                s += 'sprite {\n'
                s += 'image_path: "{}"\n'.format(os.path.join(data_dir, 'sprite.png'))
                s += 'single_image_dim: {}\n'.format(label_img_shape[3])
                s += 'single_image_dim: {}\n'.format(label_img_shape[2])
                s += '}\n'
        s += '}\n'
        f.write(s)
1225471
def create_default_config():
    
    import codecs
    config = ConfigParser.SafeConfigParser()
    config.readfp(StringIO(DEFAULT_CONFIG))

    # Load user settings
    filename = get_user_config_filename()
    if not os.path.exists(filename):
        from wizard import setup_wizard
        setup_wizard(config)
    else:
        try:
            fi = codecs.open(filename, 'r', encoding='utf-8')
            config.readfp(fi)
        finally:
            fi.close()
    return config
94017
def _create_configs(cls, site):
        
        provider = cls.name

        cls._render_config('wsgi.py', 'wsgi.py', site)

        # create yaml file
        yaml_template_name = os.path.join(provider, cls.provider_yml_name)
        cls._render_config(cls.provider_yml_name, yaml_template_name, site)

        # create requirements file
        # don't do anything if the requirements file is called requirements.txt and in the root of the project
        requirements_filename = "requirements.txt"
        if site['requirements'] != requirements_filename:   # providers expect the file to be called requirements.txt
            requirements_template_name = os.path.join(provider, requirements_filename)
            cls._render_config(requirements_filename, requirements_template_name, site)

        # create settings file
        settings_template_name = os.path.join(provider, 'settings_%s.py' % provider)
        settings_path = site['django_settings'].replace('.', '/') + '_%s.py' % provider
        cls._render_config(settings_path, settings_template_name, site)
188258
def make_config_file(guided=False):
    
    config_path = _make_config_location(guided=guided)

    config_data = make_config_data(guided=guided)

    write_config_file(config_path, config_data)
685371
def _write_config_file(items, global_vars, template, project_name, out_dir,
                       remotes):
    
    config_dir = utils.safe_makedir(os.path.join(out_dir, "config"))
    out_config_file = os.path.join(config_dir, "%s.yaml" % project_name)
    out = {"fc_name": project_name,
           "upload": {"dir": "../final"},
           "details": items}
    if remotes.get("base"):
        r_base = objectstore.parse_remote(remotes.get("base"))
        out["upload"]["method"] = r_base.store
        out["upload"]["bucket"] = r_base.bucket
        out["upload"]["folder"] = os.path.join(r_base.key, "final") if r_base.key else "final"
        if r_base.region:
            out["upload"]["region"] = r_base.region
    if global_vars:
        out["globals"] = global_vars
    for k, v in template.items():
        if k not in ["details"]:
            out[k] = v
    if os.path.exists(out_config_file):
        shutil.move(out_config_file,
                    out_config_file + ".bak%s" % datetime.datetime.now().strftime("%Y-%m-%d-%H-%M-%S"))
    with open(out_config_file, "w") as out_handle:
        yaml.safe_dump(out, out_handle, default_flow_style=False, allow_unicode=False)
    return out_config_file
763035
def CopyConfig(self):
    
    newconf = self.MakeNewConfig()
    newconf.raw_data = copy.deepcopy(self.raw_data)
    newconf.files = copy.deepcopy(self.files)
    newconf.secondary_config_parsers = copy.deepcopy(
        self.secondary_config_parsers)
    newconf.writeback = copy.deepcopy(self.writeback)
    newconf.writeback_data = copy.deepcopy(self.writeback_data)
    newconf.global_override = copy.deepcopy(self.global_override)
    newconf.context_descriptions = copy.deepcopy(self.context_descriptions)
    newconf.constants = copy.deepcopy(self.constants)
    newconf.initialized = copy.deepcopy(self.initialized)
    return newconf
572245
def base_create_agent_configurations(cls) -> ConfigObject:
        
        config = ConfigObject()
        location_config = config.add_header_name(BOT_CONFIG_MODULE_HEADER)
        location_config.add_value(LOOKS_CONFIG_KEY, str,
                                  description='Path to loadout config from runner')
        location_config.add_value(PYTHON_FILE_KEY, str,
                                  description="Bot's python file.\nOnly need this if RLBot controlled")
        location_config.add_value(BOT_NAME_KEY, str, default='nameless',
                                  description='The name that will be displayed in game')

        details_config = config.add_header_name(BOT_CONFIG_DETAILS_HEADER)
        details_config.add_value('developer', str, description="Name of the bot's creator/developer")
        details_config.add_value('description', str, description="Short description of the bot")
        details_config.add_value('fun_fact', str, description="Fun fact about the bot")
        details_config.add_value('github', str, description="Link to github repository")
        details_config.add_value('language', str, description="Programming language")

        cls.create_agent_configurations(config)

        return config
202067
def save_to_file(self, filename: str) -> ConfigFile:
        
        newclass = ConfigFile(fd=filename, load_hook=self.normal_class_hook[0],
                              dump_hook=self.normal_class_hook[1], safe_load=self.safe_load)
        return newclass
472026
def write_conf(self):
        
        f = open(self.output_filename, 'w')
        print(self.t.render(prefixes=self.prefixes), file=f)
        f.close()
935201
def config():
    
    conf = ConfigParser()
    # Set up defaults
    conf.add_section('io')
    conf.set('io', 'compression', 'zlib')

    conf.read(os.path.expanduser('~/.deepdish.conf'))
    return conf
843335
def deepcopy(self):
        
        # Save actual config to a string
        config_string = StringIO()
        self.write(config_string)

        # We must reset the buffer ready for reading.
        config_string.seek(0)

        # Create a new config object
        config_copy = ExtendedConfigParser()
        config_copy.readfp(config_string)

        return config_copy
145898
def create_config_file(access_token, ssh_key_path, ssh_user, ssh_port, region, image, size, ssh_key, private_networking, backups_enabled, ip6, timeout)
      # Default SSH Key path
      ssh_key_path = File.join('~', DEFAULT_SSH_KEY_PATH) if ssh_key_path.empty?

      ssh_user = 'root' if ssh_user.empty?

      ssh_port = DEFAULT_SSH_PORT if ssh_port.empty?

      region = DEFAULT_REGION if region.empty?

      image = DEFAULT_IMAGE if image.empty?

      size = DEFAULT_SIZE if size.empty?

      default_ssh_key = DEFAULT_SSH_KEY if ssh_key.empty?

      if private_networking.empty?
        private_networking = DEFAULT_PRIVATE_NETWORKING
      end

      backups_enabled = DEFAULT_BACKUPS_ENABLED if backups_enabled.empty?

      ip6 = DEFAULT_IP6 if ip6.empty?

      timeout = DEFAULT_TIMEOUT if timeout.empty?

      require 'yaml'
      File.open(@path, File::RDWR | File::TRUNC | File::CREAT, 0o600) do |file|
        data = {
          'authentication' => {
            'access_token' => access_token
          },
          'connection' => {
            'timeout' => timeout
          },
          'ssh' => {
            'ssh_user' => ssh_user,
            'ssh_key_path' => ssh_key_path,
            'ssh_port' => ssh_port
          },
          'defaults' => {
            'region' => region,
            'image' => image,
            'size' => size,
            'ssh_key' => ssh_key,
            'private_networking' => private_networking,
            'backups_enabled' => backups_enabled,
            'ip6' => ip6
          }
        }
        file.write data.to_yaml
      end
    end
908381
def _save_embedding_tsv(data, file_path):
    """"""
    if isinstance(data, np.ndarray):
        data_list = data.tolist()
    elif isinstance(data, NDArray):
        data_list = data.asnumpy().tolist()
    else:
        raise TypeError('expected NDArray of np.ndarray, while received type {}'.format(
            str(type(data))))
    with open(os.path.join(file_path, 'tensors.tsv'), 'w') as f:
        for x in data_list:
            x = [str(i) for i in x]
            f.write('\t'.join(x) + '\n')
1189111
def create(model_config, path, num_workers, batch_size, augmentations=None, tta=None):
    
    if not os.path.isabs(path):
        path = model_config.project_top_dir(path)

    train_path = os.path.join(path, 'train')
    valid_path = os.path.join(path, 'valid')

    train_ds = ImageDirSource(train_path)
    val_ds = ImageDirSource(valid_path)

    return TrainingData(
        train_ds,
        val_ds,
        num_workers=num_workers,
        batch_size=batch_size,
        augmentations=augmentations,
        # test_time_augmentation=tta
    )
101228
def create(model_config, batch_size, normalize=True, num_workers=0, augmentations=None):
    
    path = model_config.data_dir('mnist')

    train_dataset = datasets.MNIST(path, train=True, download=True)
    test_dataset = datasets.MNIST(path, train=False, download=True)

    augmentations = [ToArray()] + (augmentations if augmentations is not None else [])

    if normalize:
        train_data = train_dataset.train_data
        mean_value = (train_data.double() / 255).mean().item()
        std_value = (train_data.double() / 255).std().item()

        augmentations.append(Normalize(mean=mean_value, std=std_value, tags=['train', 'val']))

    augmentations.append(ToTensor())

    return TrainingData(
        train_dataset,
        test_dataset,
        num_workers=num_workers,
        batch_size=batch_size,
        augmentations=augmentations
    )
1260187
def create(fc_layers=None, dropout=None, pretrained=True):
    
    def instantiate(**_):
        return Resnet34(fc_layers, dropout, pretrained)

    return ModelFactory.generic(instantiate)
666099
def make_config_data(*, guided):
    
    config_data = {}
    config_data[INCLUDE_DIRS_KEY] = _make_include_dirs(guided=guided)
    config_data[RUNTIME_DIRS_KEY] = _make_runtime_dirs(guided=guided)
    config_data[RUNTIME_KEY] = _make_runtime()

    return config_data