docstr: problem_name: the type of problem we are working on.
     recovering: we directly try to recover the target image.§
  index: the index of the problem, inside the problem type.
     For example, if problem_name is "recovering" and index == 0,
     we try to recover the face of O. Teytaud.
docstr_tok: ["problem_name",":","the","type","of","problem","we","are","working","on",".","recovering",":","we","directly","try","to","recover","the","target","image.\u00a7","index",":","the","index","of","the","problem",",","inside","the","problem","type",".","For","example",",","if","problem_name","is","``","recovering","''","and","index","==","0",",","we","try","to","recover","the","face","of","O.","Teytaud","."]
code: def __init__(
      self,
      problem_name: str = "recovering",
      index: int = 0,
      loss: tp.Type[
          imagelosses.ImageLoss
      ] = imagelosses.SumAbsoluteDifferences,
      with_pgan: bool = False,
      num_images: int = 1,
  ) -> None:
      """
      problem_name: the type of problem we are working on.
         recovering: we directly try to recover the target image.§
      index: the index of the problem, inside the problem type.
         For example, if problem_name is "recovering" and index == 0,
         we try to recover the face of O. Teytaud.
      """
  
      # Storing high level information.
      self.domain_shape = (226, 226, 3)
      self.problem_name = problem_name
      self.index = index
      self.with_pgan = with_pgan
      self.num_images = num_images
  
      # Storing data necessary for the problem at hand.
      assert (
          problem_name == "recovering"
      )  # For the moment we have only this one.
      assert index == 0  # For the moment only 1 target.
      # path = os.path.dirname(__file__) + "/headrgb_olivier.png"
      path = Path(__file__).with_name("headrgb_olivier.png")
      image = PIL.Image.open(path).resize(
          (self.domain_shape[0], self.domain_shape[1]),
          PIL.Image.BICUBIC,
      )
      self.data = np.asarray(image)[
          :, :, :3
      ]  # 4th Channel is pointless here, only 255.
      # parametrization
      if not with_pgan:
          assert num_images == 1
          array = ng.p.Array(
              init=128 * np.ones(self.domain_shape), mutable_sigma=True
          )
          array.set_mutation(sigma=35)
          array.set_bounds(
              lower=0,
              upper=255.99,
              method="clipping",
              full_range_sampling=True,
          )
          max_size = ng.p.Scalar(
              lower=1, upper=200
          ).set_integer_casting()
          array = ng.ops.mutations.Crossover(
              axis=(0, 1), max_size=max_size
          )(array).set_name(
              ""
          )  # type: ignore
          super().__init__(loss(reference=self.data), array)
      else:
          self.pgan_model = torch.hub.load(
              "facebookresearch/pytorch_GAN_zoo:hub",
              "PGAN",
              model_name="celebAHQ-512",
              pretrained=True,
              useGPU=False,
          )
          self.domain_shape = (num_images, 512)  # type: ignore
          initial_noise = np.random.normal(size=self.domain_shape)
          self.initial = np.random.normal(size=(1, 512))
          self.target = np.random.normal(size=(1, 512))
          array = ng.p.Array(init=initial_noise, mutable_sigma=True)
          array.set_mutation(sigma=35.0)
          array = ng.ops.mutations.Crossover(axis=(0, 1))(
              array
          ).set_name("")
          self._descriptors.pop("use_gpu", None)
          super().__init__(self._loss_with_pgan, array)
  
      assert self.multiobjective_upper_bounds is None
      self.add_descriptors(loss=loss.__class__.__name__)
      self.loss_function = loss(reference=self.data)
  
imports: import os
  import itertools
  from pathlib import Path
  import cv2
  import numpy
  import PIL.Image
  import torch.nn
  import torch
  import torchvision
  from torchvision.models import resnet50
  import torchvision.transforms
  import nevergrad
  import nevergrad.common.typing
  from nevergrad.common import errors
  from ..None import base
  from .None import imagelosses
label_desc: Use image node_id 1 to create a new Image object from inherited base classes: base with example: obj = Image(problem_name, index, loss, with_pgan, num_images)