prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <issue>
  when pip version older than newest version, it calls API on every command rather than caching the information
  When I use an older pip version, I see multiple lines of output like this when I run `lightly-magic`
  ```
  ...Python/3.8/lib/python/site-packages/lightly/api/version_checking.py:57: Warning: You are using lightly version 1.1.17. There is a newer version of the package available. For compatability reasons, please upgrade your current version: pip install lightly==1.1.18
    warnings.warn(Warning(warning))
  ```
  
  Also tracking the connections it makes, it calls the API for **every** images I want to upload. So the pip does not cache the information that it is an outdated version. This is no bueno
    
    
  
  </issue>
  <code>
  [start of lightly/__init__.py]
  1 """Lightly is a computer vision framework for self-supervised learning.
  2 
  3 With Lightly you can train deep learning models using
  4 self-supervision. This means, that you don't require
  5 any labels to train a model. Lightly has been built
  6 to help you understand and work with large unlabeled datasets.
  7 It is built on top of PyTorch and therefore fully compatible 
  8 with other frameworks such as Fast.ai.
  9 
  10 The framework is structured into the following modules:
  11 
  12 - **api**: 
  13 
  14   The lightly.api module handles communication with the Lightly web-app.
  15 
  16 - **cli**:
  17 
  18   The lightly.cli module provides a command-line interface for training 
  19   self-supervised models and embedding images. Furthermore, the command-line
  20   tool can be used to upload and download images from/to the Lightly web-app.
  21 
  22 - **core**:
  23 
  24   The lightly.core module offers one-liners for simple self-supervised learning.
  25 
  26 - **data**:
  27 
  28   The lightly.data module provides a dataset wrapper and collate functions. The
  29   collate functions are in charge of the data augmentations which are crucial for
  30   self-supervised learning.
  31 
  32 - **embedding**:
  33 
  34   The lightly.embedding module combines the self-supervised models with a dataloader,
  35   optimizer, and loss function to provide a simple pytorch-lightning trainable.
  36 
  37 - **loss**:
  38 
  39   The lightly.loss module contains implementations of popular self-supervised training
  40   loss functions.
  41 
  42 - **models**:
  43 
  44   The lightly.models module holds the implementation of the ResNet as well as self-
  45   supervised methods. Currently implements:
  46 
  47   - SimCLR
  48 
  49   - MoCo
  50 
  51   - SimSiam
  52 
  53   - Barlow Twins
  54 
  55   - BYOL
  56 
  57   - NNCLR
  58 
  59 - **transforms**:
  60 
  61   The lightly.transforms module implements custom data transforms. Currently implements:
  62 
  63   - Gaussian Blur
  64 
  65   - Random Rotation
  66 
  67   - Random Solarization
  68 
  69 - **utils**:
  70 
  71   The lightly.utils package provides global utility methods.
  72   The io module contains utility to save and load embeddings in a format which is
  73   understood by the Lightly library.
  74 
  75 """
  76 
  77 # Copyright (c) 2020. Lightly AG and its affiliates.
  78 # All Rights Reserved
  79 
  80 __name__ = 'lightly'
  81 __version__ = '1.1.18'
  82 
  83 
  84 try:
  85     # See (https://github.com/PyTorchLightning/pytorch-lightning)
  86     # This variable is injected in the __builtins__ by the build
  87     # process. It used to enable importing subpackages of skimage when
  88     # the binaries are not built
  89     __LIGHTLY_SETUP__
  90 except NameError:
  91     __LIGHTLY_SETUP__ = False
  92 
  93 
  94 if __LIGHTLY_SETUP__:
  95     # setting up lightly
  96     msg = f'Partial import of {__name__}=={__version__} during build process.' 
  97     print(msg)
  98 else:
  99     # see if prefetch_generator is available
  100     try:
  101         import prefetch_generator
  102     except ImportError:
  103         _prefetch_generator_available = False
  104     else:
  105         _prefetch_generator_available = True
  106 
  107     def _is_prefetch_generator_available():
  108         return _prefetch_generator_available
  109 
  110     from lightly.core import *
  111     from lightly import active_learning
  112     from lightly import api
  113     from lightly import data
  114     from lightly import embedding
  115     from lightly import loss
  116     from lightly import models
  117     from lightly import openapi_generated
  118     from lightly import transforms
  119     from lightly import utils
  120 
  121 
  122     # check for latest version
  123     from lightly.api.version_checking import get_latest_version
  124     from lightly.api.version_checking import version_compare
  125     from lightly.api.version_checking import pretty_print_latest_version
  126 
  127     latest_version = get_latest_version(__version__)
  128     if latest_version is not None:
  129         if version_compare(__version__, latest_version) < 0:
  130             # local version is behind latest version
  131             pretty_print_latest_version(latest_version)
  132
  [end of lightly/__init__.py]
  </code>
  
  I need you to solve this issue by generating a single patch file that I can apply directly to this repository using git apply. Please respond with a single patch file in the following format.
  <patch>
  diff --git a/file.py b/file.py
  --- a/file.py
  +++ b/file.py
  @@ -1,27 +1,35 @@
   def euclidean(a, b):
  -    while b:
  -        a, b = b, a % b
  -    return a
  +    if b == 0:
  +        return a
  +    return euclidean(b, a % b)
   
   
   def bresenham(x0, y0, x1, y1):
       points = []
       dx = abs(x1 - x0)
       dy = abs(y1 - y0)
  -    sx = 1 if x0 < x1 else -1
  -    sy = 1 if y0 < y1 else -1
  -    err = dx - dy
  +    x, y = x0, y0
  +    sx = -1 if x0 > x1 else 1
  +    sy = -1 if y0 > y1 else 1
   
  -    while True:
  -        points.append((x0, y0))
  -        if x0 == x1 and y0 == y1:
  -            break
  -        e2 = 2 * err
  -        if e2 > -dy:
  -            err -= dy
  -            x0 += sx
  -        if e2 < dx:
  -            err += dx
  -            y0 += sy
  +    if dx > dy:
  +        err = dx / 2.0
  +        while x != x1:
  +            points.append((x, y))
  +            err -= dy
  +            if err < 0:
  +                y += sy
  +                err += dx
  +            x += sx
  +    else:
  +        err = dy / 2.0
  +        while y != y1:
  +            points.append((x, y))
  +            err -= dx
  +            if err < 0:
  +                x += sx
  +                err += dy
  +            y += sy
  +
  +    points.append((x, y))
       return points
  
  </patch>
golden_diff: diff --git a/lightly/__init__.py b/lightly/__init__.py
  --- a/lightly/__init__.py
  +++ b/lightly/__init__.py
  @@ -80,6 +80,7 @@
   __name__ = 'lightly'
   __version__ = '1.1.18'
   
  +from multiprocessing import current_process
   
   try:
       # See (https://github.com/PyTorchLightning/pytorch-lightning)
  @@ -118,14 +119,15 @@
       from lightly import transforms
       from lightly import utils
   
  +    if current_process().name == 'MainProcess':
  +        # check for latest version
  +        from lightly.api.version_checking import get_latest_version
  +        from lightly.api.version_checking import version_compare
  +        from lightly.api.version_checking import pretty_print_latest_version
   
  -    # check for latest version
  -    from lightly.api.version_checking import get_latest_version
  -    from lightly.api.version_checking import version_compare
  -    from lightly.api.version_checking import pretty_print_latest_version
  +        latest_version = get_latest_version(__version__)
  +        if latest_version is not None:
  +            if version_compare(__version__, latest_version) < 0:
  +                # local version is behind latest version
  +                pretty_print_latest_version(latest_version)
   
  -    latest_version = get_latest_version(__version__)
  -    if latest_version is not None:
  -        if version_compare(__version__, latest_version) < 0:
  -            # local version is behind latest version
  -            pretty_print_latest_version(latest_version)
  
verification_info: {"golden_diff": "diff --git a/lightly/__init__.py b/lightly/__init__.py\n--- a/lightly/__init__.py\n+++ b/lightly/__init__.py\n@@ -80,6 +80,7 @@\n __name__ = 'lightly'\n __version__ = '1.1.18'\n \n+from multiprocessing import current_process\n \n try:\n     # See (https://github.com/PyTorchLightning/pytorch-lightning)\n@@ -118,14 +119,15 @@\n     from lightly import transforms\n     from lightly import utils\n \n+    if current_process().name == 'MainProcess':\n+        # check for latest version\n+        from lightly.api.version_checking import get_latest_version\n+        from lightly.api.version_checking import version_compare\n+        from lightly.api.version_checking import pretty_print_latest_version\n \n-    # check for latest version\n-    from lightly.api.version_checking import get_latest_version\n-    from lightly.api.version_checking import version_compare\n-    from lightly.api.version_checking import pretty_print_latest_version\n+        latest_version = get_latest_version(__version__)\n+        if latest_version is not None:\n+            if version_compare(__version__, latest_version) < 0:\n+                # local version is behind latest version\n+                pretty_print_latest_version(latest_version)\n \n-    latest_version = get_latest_version(__version__)\n-    if latest_version is not None:\n-        if version_compare(__version__, latest_version) < 0:\n-            # local version is behind latest version\n-            pretty_print_latest_version(latest_version)\n", "issue": "when pip version older than newest version, it calls API on every command rather than caching the information\nWhen I use an older pip version, I see multiple lines of output like this when I run `lightly-magic`\r\n```\r\n...Python/3.8/lib/python/site-packages/lightly/api/version_checking.py:57: Warning: You are using lightly version 1.1.17. There is a newer version of the package available. For compatability reasons, please upgrade your current version: pip install lightly==1.1.18\r\n  warnings.warn(Warning(warning))\r\n```\r\n\r\nAlso tracking the connections it makes, it calls the API for **every** images I want to upload. So the pip does not cache the information that it is an outdated version. This is no bueno\r\n  \r\n  \n", "before_files": [{"content": "\"\"\"Lightly is a computer vision framework for self-supervised learning.\n\nWith Lightly you can train deep learning models using\nself-supervision. This means, that you don't require\nany labels to train a model. Lightly has been built\nto help you understand and work with large unlabeled datasets.\nIt is built on top of PyTorch and therefore fully compatible \nwith other frameworks such as Fast.ai.\n\nThe framework is structured into the following modules:\n\n- **api**: \n\n  The lightly.api module handles communication with the Lightly web-app.\n\n- **cli**:\n\n  The lightly.cli module provides a command-line interface for training \n  self-supervised models and embedding images. Furthermore, the command-line\n  tool can be used to upload and download images from/to the Lightly web-app.\n\n- **core**:\n\n  The lightly.core module offers one-liners for simple self-supervised learning.\n\n- **data**:\n\n  The lightly.data module provides a dataset wrapper and collate functions. The\n  collate functions are in charge of the data augmentations which are crucial for\n  self-supervised learning.\n\n- **embedding**:\n\n  The lightly.embedding module combines the self-supervised models with a dataloader,\n  optimizer, and loss function to provide a simple pytorch-lightning trainable.\n\n- **loss**:\n\n  The lightly.loss module contains implementations of popular self-supervised training\n  loss functions.\n\n- **models**:\n\n  The lightly.models module holds the implementation of the ResNet as well as self-\n  supervised methods. Currently implements:\n\n  - SimCLR\n\n  - MoCo\n\n  - SimSiam\n\n  - Barlow Twins\n\n  - BYOL\n\n  - NNCLR\n\n- **transforms**:\n\n  The lightly.transforms module implements custom data transforms. Currently implements:\n\n  - Gaussian Blur\n\n  - Random Rotation\n\n  - Random Solarization\n\n- **utils**:\n\n  The lightly.utils package provides global utility methods.\n  The io module contains utility to save and load embeddings in a format which is\n  understood by the Lightly library.\n\n\"\"\"\n\n# Copyright (c) 2020. Lightly AG and its affiliates.\n# All Rights Reserved\n\n__name__ = 'lightly'\n__version__ = '1.1.18'\n\n\ntry:\n    # See (https://github.com/PyTorchLightning/pytorch-lightning)\n    # This variable is injected in the __builtins__ by the build\n    # process. It used to enable importing subpackages of skimage when\n    # the binaries are not built\n    __LIGHTLY_SETUP__\nexcept NameError:\n    __LIGHTLY_SETUP__ = False\n\n\nif __LIGHTLY_SETUP__:\n    # setting up lightly\n    msg = f'Partial import of {__name__}=={__version__} during build process.' \n    print(msg)\nelse:\n    # see if prefetch_generator is available\n    try:\n        import prefetch_generator\n    except ImportError:\n        _prefetch_generator_available = False\n    else:\n        _prefetch_generator_available = True\n\n    def _is_prefetch_generator_available():\n        return _prefetch_generator_available\n\n    from lightly.core import *\n    from lightly import active_learning\n    from lightly import api\n    from lightly import data\n    from lightly import embedding\n    from lightly import loss\n    from lightly import models\n    from lightly import openapi_generated\n    from lightly import transforms\n    from lightly import utils\n\n\n    # check for latest version\n    from lightly.api.version_checking import get_latest_version\n    from lightly.api.version_checking import version_compare\n    from lightly.api.version_checking import pretty_print_latest_version\n\n    latest_version = get_latest_version(__version__)\n    if latest_version is not None:\n        if version_compare(__version__, latest_version) < 0:\n            # local version is behind latest version\n            pretty_print_latest_version(latest_version)\n", "path": "lightly/__init__.py"}]}