instruction_seed
stringlengths
0
26.4k
source
stringclasses
4 values
You are tasked with creating a Python function that converts a Caffe model file to a TensorFlow checkpoint format. The function should assume that the network built is equivalent to or a subset of the Caffe definition. You are provided with the initial code snippet as a starting point. Your task is to complete the func...
codefeedback
You are tasked with implementing a CatalogueValidator class in Java, which is responsible for validating a catalogue of items. The CatalogueValidator class has been provided with a code snippet for inspiration. Your task is to complete the implementation of the CatalogueValidator class by adding the necessary methods t...
codefeedback
You are given a hashed message and a string of characters. Your task is to find the original message by brute-forcing all possible combinations of the characters in the string and hashing each combination until a match is found with the given hashed message. You are provided with the following information: - The strin...
codefeedback
You are tasked with implementing a Python decorator that logs the execution time of a function. The decorator should print the name of the function, its execution time, and the arguments passed to the function. You are provided with a partial implementation of the `timing` decorator, which uses the `time` module to mea...
codefeedback
You are tasked with creating a Java Spring Boot application that handles user authentication using JSON Web Tokens (JWT). Your goal is to implement a method that configures a JwtAccessTokenConverter bean, which is responsible for converting JWT tokens to OAuth2 tokens and vice versa. You need to write a method that re...
codefeedback
You are tasked with implementing a simplified version of a blockchain wallet in TypeScript. The provided code snippet is a part of the wallet class, which includes a method for sending transactions. Your task is to complete the implementation of the `send` method and ensure that it adheres to the specified requirements...
codefeedback
You are tasked with implementing a class that represents a simple grid layout system for a graphical user interface (GUI) application. The grid layout should support adding and positioning widgets within a grid structure. Each widget can have a specified size and appearance properties. Your task is to create a Python ...
codefeedback
You are tasked with simulating a configuration setup for a software system. The configuration is represented as a dictionary `config`, where keys are configuration options and values are the corresponding settings. Additionally, there are some function calls and a modification to the `sys.argv` list. Given the provide...
codefeedback
You are tasked with creating a Python function to generate a photo montage using the `montage` command from the ImageMagick library. The function should take a list of input image files and an output path as parameters. The `montage` command will arrange the input images into a grid and create a single output image fil...
codefeedback
You are given a matrix `x` of shape (m, n) containing probabilities for each of the n classes for m instances. Your task is to write a function `top_n_probabilities(x, n)` that returns the top n probabilities for each instance in the matrix. The function should take in the following parameters: - `x`: a 2D tensor repr...
codefeedback
You are given a snippet of code that appears to be incomplete. Your task is to complete the code by implementing a function that calculates the sum of all even numbers in a given array. The function should take an array of integers as input and return the sum of all even numbers in the array. Complete the following Ja...
codefeedback
You are tasked with implementing a generic stack data structure in Rust. The stack should be able to store elements of any primitive data type. Your implementation should include the following functionalities: 1. `new`: Create a new empty stack. 2. `push`: Add an element to the top of the stack. 3. `pop`: Remove and r...
codefeedback
You are tasked with creating a PHP class that represents a user in a system. The class should have a method to establish a one-to-one relationship with another class representing the user's type. The method should take the namespace of the related class, the foreign key in the current class, and the corresponding forei...
codefeedback
You are tasked with creating a Python function that simulates the configuration of network interfaces and bridges using the `ip` command in a Linux environment. The function should take a list of commands as input and return the final state of the network interfaces and bridges in a dictionary format. The input list w...
codefeedback
You are tasked with implementing a function to calculate the eigenvalues and eigenvectors of a given matrix using the power iteration method. The power iteration method is an iterative algorithm that can be used to find the dominant eigenvalue and its corresponding eigenvector of a matrix. The dominant eigenvalue is th...
codefeedback
You are tasked with implementing a Python class for managing and manipulating spot data. Spots are represented as a collection of coordinates in a 2D space. Your goal is to create a class that can save and load spot data to and from a Zarr archive, a format commonly used for storing large arrays of data efficiently. Y...
codefeedback
You are tasked with creating a Python class to represent a material and its properties. The class should have methods to set and retrieve the material's properties, as well as a method to display a summary of the material's information. Create a Python class called `Material` with the following specifications: - The c...
codefeedback
You are given a Python code snippet that processes molecular structures using the OpenEye OEChem toolkit. Your task is to create a function that calculates the torsion angle between four atoms in a molecule and returns the corresponding InChI key for the specific dihedral angle. You need to implement a function `calcu...
codefeedback
You are tasked with implementing a function that calculates the sum of all prime numbers within a given range. A prime number is a natural number greater than 1 that has no positive divisors other than 1 and itself. Your function should take two integers, `start` and `end`, as input and return the sum of all prime numb...
codefeedback
You are tasked with creating a Python class that converts XML data into a specific format. The given code snippet is a partial implementation of a `SubstanceCVConverter` class that inherits from `XmlConverter`. The `convert` method takes an XML element `xml` as input and returns a dictionary containing specific attribu...
codefeedback
You are tasked with creating a program that processes user input for a password and validates its strength based on certain criteria. The password strength is determined by the following rules: 1. The password must be at least 8 characters long. 2. The password must contain at least one uppercase letter, one lowercase ...
codefeedback
You are tasked with implementing a class for managing test data in a testing framework. The provided code snippet is part of the implementation of the `CTSTestData` class. The class is responsible for managing test suites and their associated tests. The code snippet shows a part of the destructor for the `CTSTestData`...
codefeedback
You are tasked with creating a Python function that connects to a database using the `psycopg2` library and retrieves data from a specified table. Your function should handle potential errors and exceptions that may occur during the database connection process. You are provided with a code snippet that attempts to est...
codefeedback
You are given a log of responses from a group of people answering a series of yes-or-no questions. Each person's answers are recorded on a separate line, and the log is terminated by an empty line. Your task is to calculate the total count of questions to which anyone in the group answered "yes" and the total count of ...
codefeedback
You are given a singly linked list containing both even and odd integers. Your task is to write a function to rearrange the list such that all even integers appear before the odd integers while maintaining the relative order of even and odd integers. Implement the function `rearrangeEvenOdd` that takes the head of the ...
codefeedback
You are tasked with implementing a function to process an image using Python's Pillow library. The function should take an input image and perform the following operations: 1. Crop the image to a specified region defined by the coordinates (x, 0, x+w, w). 2. Resize the cropped region to a fixed size of 320x320 pixels. ...
codefeedback
You are tasked with creating a Django view for uploading files and handling file uploads in a web application. Your task is to implement a Django view that allows users to upload files using a form-data request. The view should handle the file upload and save the uploaded file to a specific location on the server. You...
codefeedback
You are tasked with implementing a function that processes an array of options and their corresponding values. The function should construct a new array where the keys are the options and the values are the corresponding values. Additionally, the function should handle cases where the options or values are missing or e...
codefeedback
You are tasked with simulating a memory reallocation process. In this process, you are given a list of memory banks, each containing a certain number of blocks. The goal is to reallocate the blocks in a specific pattern until a configuration is repeated, indicating a cycle. Your task is to determine the size of the cyc...
codefeedback
You are tasked with creating a Python decorator that limits the number of times a function can be called. Your decorator, `call_limit`, should take an integer `count` as an argument, representing the maximum number of times the decorated function can be called. If the decorated function is called more than `count` time...
codefeedback
You are tasked with creating a script to automate the generation and validation of compressed archive files from a Git repository. Your script should handle the generation of the archive file and the verification of its SHA256 hash. Additionally, it should handle the scenario where the specified Git tag does not exist....
codefeedback
You are tasked with implementing a custom layer in a neural network using TensorFlow. The custom layer, named "last_class_center", is designed to calculate the center of the last class in the input data. The layer has a shape of [1, num_class, channels], where num_class represents the number of classes in the input dat...
codefeedback
You are tasked with implementing a utility function that processes different types of actions for interacting with web elements in an automated testing framework. The function should take in an action object and perform the corresponding action on a web element. The action object can have two different interfaces: `Ac...
codefeedback
You are tasked with creating a program that simulates the process of managing Git tags. Git tags are used to mark specific points in a repository's history as being important. Your program should be able to perform operations such as creating new tags, listing existing tags, deleting tags, and pushing these changes to ...
codefeedback
You are tasked with creating a Python function that reads a directory and returns a list of all files with a specific file extension. You should also handle cases where the directory does not exist or is not accessible. Your function should have the following signature: ```python def find_files_by_extension(directory...
codefeedback
You are tasked with creating a script to process video files. The script should take a video file as input and perform the following tasks: 1. Rename the output file by replacing the ".mp4" extension with "_cut.mp4". 2. If a duration is provided, the script should cut the video to the specified duration; otherwise, it...
codefeedback
You are tasked with implementing a custom login message feature for an admin management system. The system provides an `AdminList` class with methods to manage admin entries. The `setCustomLoginMessage` method allows setting a custom login message for a specific admin entry identified by a UUID. The `save` method is us...
codefeedback
You are tasked with creating a Python function that visualizes a given graph using the NetworkX library. The function should take a graph object as input and produce a visualization of the graph with labeled nodes and edges. The provided code snippet serves as a starting point for your function. Your task is to complet...
codefeedback
You are tasked with implementing a custom data structure called `CustomLinkedList` in C#. The `CustomLinkedList` should support the basic operations of a singly linked list, including insertion, deletion, and traversal. Additionally, you need to implement a method to reverse the linked list. Your task is to complete t...
codefeedback
You are tasked with implementing a segmented replay buffer for a reinforcement learning agent. A segmented replay buffer is a data structure used in deep reinforcement learning to store and sample experiences for training a neural network. It consists of multiple segments, each with its own maximum capacity. When addin...
codefeedback
You are tasked with creating a Python function that manipulates a given string based on specific rules. The function should take a string as input and perform the following operations: 1. Convert the string to lowercase. 2. Replace all occurrences of the letter 'e' with '3'. 3. Replace all occurrences of the letter 's...
codefeedback
You are given two strings, S1 and S2. You are also given an empty map and an initial value of 0. Your task is to write a function that populates the map with the frequency of each character in S1 and then calculates the sum of the frequencies of characters in S2. The function should return the sum as the final output. ...
codefeedback
You are tasked with implementing a program that simulates a simple banking system. The program should allow users to create accounts, deposit and withdraw funds, and check their balance. Each account should have a unique account number, and the program should support multiple accounts. The program should also be able t...
codefeedback
You are tasked with creating a user serialization and deserialization system for a web application. The system should be able to validate and process user data, including the username, password, and admin status. The provided code snippet contains a portion of the test suite for the user serialization and deserializati...
codefeedback
You are tasked with implementing a custom data structure that supports storing and retrieving key-value pairs, similar to a dictionary or map. However, this data structure should have the ability to store JSON objects as values and provide a method to set a JSON object for a given key. You are provided with a Swift co...
codefeedback
You are tasked with creating a script to automate the download and repository creation process for a set of packages in a CentOS environment. The script should utilize the `yumdownloader` and `createrepo` commands to achieve this. Your script should take a list of package names as input and download these packages alo...
codefeedback
You are tasked with implementing a function to evaluate the response of an API request. The function should handle cases where the data is invalid but the response is valid. You are provided with a code snippet that sets up the API request and response handling. Your task is to write the `evalInvalidResponseTest` funct...
codefeedback
You are tasked with implementing a TypeScript function that validates the structure of a given interface and returns a list of its properties along with their types. The interface will be provided as a string in the form of TypeScript code. You need to create a function `interfaceProperties` that takes a string repres...
codefeedback
You are working on a project that involves analyzing the stability of control systems. As part of this project, you need to implement a Python function that utilizes the carma_process and get_ar_roots functions from the samplers module to simulate a continuous-time autoregressive moving average (CARMA) process and then...
codefeedback
You are tasked with creating a Django model for a speech summarization application. The model should include fields for video path, name, user ID, and split speech details. The video path should be a file field with the option for null values, and it should be uploaded to a user-specific directory. Additionally, the vi...
codefeedback
You are tasked with implementing a generic function for making HTTP requests in a TypeScript application. The function will handle both GET and POST requests and will be typed to accept a request body and return a response in JSON format. You are provided with a code snippet that outlines the function signature and it...
codefeedback
You are tasked with implementing a function to calculate the area of an oriented bounding box in a 2D space. An oriented bounding box is a rectangle that is not necessarily aligned with the x and y axes. The bounding box is defined by its center point and two half-lengths along its local x and y axes. You are given th...
codefeedback
You are tasked with implementing a function that extracts the UUID (Universally Unique Identifier) from a System Information (SMBIOS) data structure. The SMBIOS data is stored in a byte array and contains various system information types. The function should locate the System Information type within the byte array and ...
codefeedback
You are tasked with implementing a program that can efficiently determine the frequency of each word in a given text. Your program should ignore punctuation and consider words regardless of their case (i.e., "Hello" and "hello" should be considered the same word). Additionally, the program should exclude common stop wo...
codefeedback
You are tasked with creating a custom React component that manages the parallel execution of animations. The component, named `Parallel`, takes in a set of animations and a boolean prop `shouldStart`, which determines whether the animations should start immediately upon rendering. The `Parallel` component utilizes a `R...
codefeedback
You are given a list of integers representing the scores of a game. Your task is to write a function that calculates the average score of the game, excluding the highest and lowest scores. Write a function `calculate_average_score(scores: List[int]) -> float` that takes in a list of integers `scores` and returns the a...
codefeedback
You are working on a computer vision project and are tasked with implementing a custom dataset class for image data. The dataset contains images and their corresponding labels, which may include both flat labels and branch labels. The dataset class needs to handle the processing of the data, including transforming the ...
codefeedback
You are tasked with implementing a histogram plotting function for a data visualization library. The function should take in a dataset and plot a 2D histogram with customizable axes and color palette. Your task is to write a function that generates the necessary code to create the histogram plot using the given data an...
codefeedback
You are tasked with creating a Java program that processes an array of integers to perform a specific operation. The program should take an input array and return a modified array based on the following rules: 1. If the input array contains any negative numbers, they should be replaced with 0. 2. If the input array co...
codefeedback
You are given a string containing a series of parentheses. Your task is to write a function to determine if the parentheses are balanced. A string of parentheses is considered balanced if every opening parenthesis has a corresponding closing parenthesis and they are properly nested. Write a function `isBalancedParenth...
codefeedback
You are tasked with implementing a pathfinding algorithm for a 2D grid-based game. The game world consists of a grid of cells, and the player-controlled character needs to navigate from its current position to a target cell. The character can move in four directions: up, down, left, and right. The grid is represented a...
codefeedback
You are tasked with implementing a Python function to decode camera-specific MakerNote formats. The MakerNote is the data that comprises this MakerNote, and it may contain pointers that reference other parts of the file. Your task is to write a function that can decode the MakerNote data and extract relevant informatio...
codefeedback
You are tasked with implementing a Python class that simulates a simple library management system. The library contains books, and patrons can borrow and return books. Your task is to create a `Library` class with the following functionalities: - Add a book to the library. - Remove a book from the library. - Display th...
codefeedback
You are tasked with optimizing the hyperparameters for a machine learning model using the Nevergrad optimization library. The objective is to minimize a given cost function by finding the optimal values for the hyperparameters. The cost function is provided as a Python function `fake_training`, which takes three input ...
codefeedback
You are tasked with implementing a function that calculates the maximum sum of a subarray within a given array of integers. A subarray is defined as a contiguous segment of the array. Your function should take an array of integers as input and return the maximum sum of any subarray within the array. For example, given...
codefeedback
You are tasked with implementing a program that can parse and analyze a Swift Package Manager (SPM) manifest file to extract specific information. The SPM manifest file is written in Swift Package Description language and contains metadata about the package, its dependencies, and targets. Your program needs to extract...
codefeedback
You are tasked with implementing a circular buffer data structure in Python. A circular buffer is a fixed-size buffer that overwrites old data with new data when the buffer is full. Your task is to implement the `CircularBuffer` class with the following specifications: - The class should have a constructor that takes ...
codefeedback
You are given a code snippet representing an SVG icon. Your task is to write a program that parses the SVG path data and counts the occurrences of each type of path command (M, L, H, V, C, S, Q, T, A, Z) in the given SVG path. The SVG path data is represented by the `d` attribute in the `<path>` tag. The path data con...
codefeedback
You are tasked with creating a custom error handling mechanism for a Rust application using the `thiserror` and `tonic` crates. The `thiserror` crate allows for the creation of custom error types, while the `tonic` crate provides utilities for working with gRPC services. Your goal is to define a custom error type calle...
codefeedback
You are working on a ray tracing application and need to implement a function to calculate the intersection point of a ray with a plane. The ray is represented by its origin and direction, and the plane is defined by its normal vector and a point on the plane. You are given the following code snippet as a starting poin...
codefeedback
You are tasked with creating a program that analyzes the distribution of words in a given text file. Your program should read the text file, tokenize the words, and then count the frequency of each word. Additionally, the program should ignore common stop words (e.g., "the", "and", "is") and should be case-insensitive ...
codefeedback
You are working on a computer vision project and need to implement a feature detection algorithm using the Hessian matrix. The Hessian matrix is a square matrix of second-order partial derivatives of a scalar function. In this problem, you are tasked with implementing a function to detect features in an image using the...
codefeedback
You are working on a cloud management system that interacts with OpenStack APIs. The code snippet provided is a part of a Python script that uses the `openstackx` library to manage instances in an OpenStack cloud environment. The script defines two classes, `TerminateInstance` and `RebootInstance`, which are used to pe...
codefeedback
You are tasked with implementing a class that represents a graph data structure. The class should have the following properties and methods: Properties: - `is_unique`: A read-only property that returns a boolean value indicating whether the graph has unique nodes. Methods: - `_reset_random_node`: A method that resets...
codefeedback
You are given a list of integers `nums` representing the values of Roman numerals in descending order. Your task is to write a function that converts an integer `num` into its Roman numeral representation using the values provided in the `nums` list. The Roman numeral system uses combinations of letters to represent n...
codefeedback
You are tasked with implementing a memory allocator for a custom programming language. The memory allocator consists of several modules and a public interface. Your goal is to create a memory allocator that efficiently manages memory allocation and deallocation for the language's runtime environment. The provided code...
codefeedback
You are tasked with creating a Python program that preprocesses data and builds a decision tree for classification. The program should consist of two main components: a preprocessing module and a decision tree module. The preprocessing module, contained in a file named `preprocess.py`, should include a function called...
codefeedback
You are tasked with creating a program that measures the execution time of different functions and displays the duration in nanoseconds along with the function name. You are given a code snippet that demonstrates how the duration and function name are printed. Your task is to implement a function `measure_execution_ti...
codefeedback
You are tasked with creating a script that monitors the performance of a web server and restarts it if it becomes unresponsive. Your script should be able to start the web server, monitor its performance, and restart it if necessary. Your script should take the following parameters: - `start_command`: The command to s...
codefeedback
You are working on a project that involves accessing and processing data from the MICA (Mission Operations and Command Automation) archive. The MICA archive provides access to various levels of data products for different missions. In this scenario, you are tasked with writing a Python script to interact with the MICA ...
codefeedback
You are tasked with implementing a shell script that processes command-line arguments related to address types. The script should handle two specific options: `-at` and `-w`. The `-at` option requires an argument specifying the address type, while the `-w` option does not require any additional arguments. If the `-at` ...
codefeedback
You are tasked with implementing a health check monitoring system for a web application using ASP.NET Core. The system should utilize SQLite as the storage for health check data. Your goal is to create a custom health check endpoint and integrate it with the Health Checks UI in the application. Your task is to write t...
codefeedback
You are tasked with creating a program that simulates a simple file inclusion mechanism. Your program should read a given file and include the contents of another file at a specific location within the first file. The included file should be inserted at the position of a designated placeholder within the first file. Y...
codefeedback
You are tasked with creating a Python program that processes a dataset of text documents and calculates the similarity between each pair of documents using a specific algorithm. The program should then save the calculated similarities to a file in a specified format. Your task is to implement a function `calculate_doc...
codefeedback
You are tasked with implementing a pagination feature for a web application. The code snippet provided is a part of a web page that displays a list of sectors and their corresponding page numbers. The code uses a loop to generate a list of page numbers and a placeholder for skipped pages represented by dots. Your task...
codefeedback
You are given a JavaScript object representing a nested data structure. Your task is to write a function that flattens this object into a single-level object, where the keys are the concatenated keys from the original object and the values are the corresponding leaf nodes. For example, given the following input object...
codefeedback
You are tasked with implementing a commentizer function that will process a series of comments based on a given condition. The function should take in a boolean value, answer2, and a list of comments. If answer2 is True, the function should set the is_correct variable to True. If answer2 is False, the function should s...
codefeedback
You are tasked with implementing a token-based authentication system for a web application. The provided code snippet includes a function that generates a JSON Web Token (JWT) and a class for handling user login requests. Your goal is to extend the functionality by implementing a token validation mechanism and integrat...
codefeedback
You are tasked with implementing a simplified version of a snapshot file system. The `Snapshotfile` class is used to manage snapshots of a file and is defined by the `SnapshotfileProtocol`. Your goal is to create a method within the `Snapshotfile` class that allows for the creation of a new snapshot of a file. The meth...
codefeedback
You are tasked with creating a function that computes the pose of an object using OpenCV in Rust. The function should take in an image and return the pose of the object in the image. Your task is to implement the `compute_pose` function, which takes an image as input and returns the pose of the object in the image. Th...
codefeedback
You are tasked with implementing a class for a statistical observational method called "VarianceCombined". The class should inherit from a parent class called "ObservationalMethod". The parent class has a method that adds noise to an input array and returns the modified array along with a unit string. The "VarianceComb...
codefeedback
You are given a 2D grid of size `rows` x `cols`. Each cell in the grid contains a non-negative integer value. Your task is to write a function to find the maximum sum of a path from the top-left cell to the bottom-right cell. The path should only move right or down at each step. For example, given the following 4x4 gr...
codefeedback
You are tasked with creating a program that simulates a simple online auction system. The program should allow users to place bids on items and display the current highest bid for each item. The auction system should also keep track of the bidding history for each item. Your task is to implement the `AuctionItem` clas...
codefeedback
You are tasked with creating a script to automate the process of deploying a root file system onto a loopback device in a Linux environment. The script should perform the following steps: 1. Show the partition table of the loopback device. 2. Add the partition table of the loopback device. 3. Create an ext4 file syste...
codefeedback
You are tasked with implementing a function to parse JSON data representing GitHub issues into a structured format. The provided code snippet is a partial representation of the `Issue` struct in Rust, which is used to model GitHub issues. Your task is to complete the `Issue` struct and implement a function to parse JSO...
codefeedback
You are tasked with implementing a custom Enum class in Python that defaults to the first value in the Enum list. Your task is to create a class `DefaultEnum` that inherits from `Enum` and overrides the `__prepare__` method to set the default value. Your `DefaultEnum` class should have the following behavior: - If no ...
codefeedback
You are tasked with implementing a function to calculate the correlation coefficient and create a scatter plot to visualize the relationship between two given arrays of numerical data. The function should handle cases where the input arrays have different lengths and raise a ValueError in such instances. Additionally, ...
codefeedback
You are given a code snippet that initializes a variable `num` to 1 and an empty list `items`. The code then enters an infinite loop. Your task is to complete the code by adding functionality that allows the user to input integers and store them in the `items` list until the user enters a negative number. Once a negati...
codefeedback
You are tasked with creating a user authentication system for a web application using Swift and the Vapor framework. The `UserController` class is responsible for managing user authentication and registration. The provided code snippet shows the initial setup of the `UserController` class, including the routing for log...
codefeedback
You are tasked with implementing a class for handling XML import operations in a document processing application. The given code snippet is a part of a method responsible for creating an appropriate import context based on the input parameters. The method attempts to obtain a stream for a graphic object URL from a base...
codefeedback